Traevel 216 Light Poster

as this is to demonstrate and capture your understanding on the
subject matter.

Your understanding, not our understanding.

Read the rules. Do work first, then get help.

Free tip: Vogella tutorials.

Traevel 216 Light Poster

Ditto, and well done indeed.

Traevel 216 Light Poster

For the single-table syntax, the DELETE statement deletes rows from tbl_name and returns a count of the number of deleted rows.

What would be the use of a *?

Also, mysql_query is deprecated and the way you are using it is dangerous.

Traevel 216 Light Poster

That site has books that can be:

  1. Downloaded
  2. Bought on paper
  3. Read online

Did you even take the time to look at them? People can learn programming all on their own using quality books like that, your answer strongly suggests you are not one of those people.

Traevel 216 Light Poster

but I could not figure out how to test the value of the user input along with the isValid(String test) method

Why not use two? A number and a String would require different tests anyway. I would keep the scanner outside of it though, less confusing that way.

Something like:

String userinput;

// example with Strings

do{
    userinput = keyboard.nextLine();

    // do stuff here

}while(!isValidString(userinput));


// stuff inbetween


// example with numbers

do{
    userinput = keyboard.nextLine();

    // do stuff here

}while(!isValidNumber(userinput));

With validation methods something like:

private boolean isValidNumber(final String test){
    try{
        int number = Integer.parseInt(test);

        if(number < 2){

            // perhaps a printline here if you want to
            // inform the user, although a more proper way
            // would be to throw a custom exception holding
            // the error message. That way this method will
            // be even more "standalone" and could be used
            // by all sorts of classes to validate numbers
            // who can deal with the exceptions in their
            // own ways

            return false;
        }
    }catch(NumberFormatException e){

        // same thing about exceptions here

        return false;
    }

    // more tests here

    // all tests were passed so it must be valid
    return true;
}

private boolean isValidString(final String test){

    if(test == null | "".equals(test)){

        // again, same thing about exceptions

        return false;
    }

    // more tests here

    // all tests passed so it's valid
    return true;
}

In my opinion it's a good habit to get used to doing the (slightly unnatural …

Traevel 216 Light Poster

Are you running them after the elements have been loaded?

Traevel 216 Light Poster

Try

.input-icon-wrapper {
    position: relative;
}
.input-icon-field {
    padding-left: 15px;    
}
.input-icon {
    position: absolute;
    top: 3px;
    left: 2px;
}

and

<div class="input-icon-wrapper">
    <span class="ui-icon ui-icon-person input-icon"></span>
    <input type="text"
           class="input-icon-field" 
           placeholder="Username" />
</div>

to get

2015-01-07--1420621621_202x32_scrot.png

Though you might want to consider using your own icons, or glyphicons for instance if you need more flexibility.

minitauros commented: Nice 'n simple :) +7
Traevel 216 Light Poster

But I am new be in seo so can suggest me which steps i wan't follow to improvement of site.

From your own website:

SEO & Web Marketing
Specializing in Business & Marketing Analysis, Search Engine Optimization tools, Google, Bing, Yahoo and Social Media outlets. Put your business or idea in front of YOUR clientele.
(...)
Internet marketing is technical, detailed work, but we offer what it takes to succeed.

Maybe you should hire yourself to solve it.

Traevel 216 Light Poster

shows me a quick glimpse

That's the echo $v1's I put in to test the other time. Just delete both and it shouldn't print to screen anymore.

Traevel 216 Light Poster

You could have a click on a row call a function that will collect all the values in said row and insert them into the calculator fields. I would suggest using jQuery for ease and speed. You could use

  • selectors for selecting certain elements
  • .click() for registering a row click
  • .after() and .append() to attach new rows to a table
  • .val() for getting/setting the value of an input
  • .html() for getting/setting the inner html of an element (i.e. TD)

You could give every row a number and use that as an identifier for the click function, or you could use the keyword this to get the row element the click was made on.

Traevel 216 Light Poster

You're overriding the $message with the HTML in $v1.

$message = $_POST["message"];

$v1 = "
<html>
<body>
<style>
#disclosure {font-size: 8px; color: #333;}
h1 {color:#000066;}
table {border:1px solid black;}
</style>
<img src= 'site.png' />
<table rules='all' style='border-color: #ffb300;' cellpadding='10' width='500px'>
<tr style='background: #ffb300;'><td><strong>Email Confirmation</strong>
<tr style='background: #fafafa;'><td>Hello <strong> $name</strong>, your message has been recieved! We will contact you shortly! <br><br>Best, <br>Me<br>An awesome person<br><br>Follow Us On:<br><a href='http://www.facebook.com'><img src='facebook_hover.png' width='18' height='18'></a><a href='http://twitter.com'><img src='twitter_hover.png' width='18' height='18'></a><a href='http://google.com'><img src='gplus_hover.png' width='18' height='18'></a><br><div id='disclosure' align='right'>©me™ All Rights Reserved 2014-2014 </div>
</table>
</body>
</html> ";

$message = $v1; 

Store $_POST['message'] in $user_message or something so you can use it for the CSV.

Traevel 216 Light Poster

@Traveal Sorry but i cant understand what you want to convey , Can you eloberate.

Just picked up where I left off yesterday, wasn't a response to something you said.

<M/> commented: Thanks :) +0
Traevel 216 Light Poster

@Traevel, i sent you a link to the page, idk if that will help

That is an interesting form layout, nice!

I took your updated code, after commenting out the mail and replacing with print (and self post again) it seems to work here, variables are correct although the second mail (as confirmation) has no variables in it except one that was wrong ($first_name instead of $name). When I run it I get the following result (fingers crossed for attachment to show up)

2014-12-28--1419773987_562x817_scrot.png

Here's the code, just uncomment the scripts and mail functions again.

  <?php 
    $name = $_POST["name"];
    $email = $_POST["email"];
    $phone = $_POST["phone"];
    $meeting_type = $_POST["meeting_type"];
    $time = $_POST["time"];
    $message = $_POST["message"];
    $to      = 'email@gmail.com';
    $subject = 'Contact Form Submission';

    $v1 = "
            <html> 
            <body> 
            <style>
                h1 {color:#000066;}
                table {border:1px solid black; background: #e3f0ff;}
            </style>
            <h1>Hello, this form has been submitted!</h1>
            <img src= 'logo.png' />
            <table rules='all' style='border-color: #ffb300;' cellpadding='10' width='500px'>
                <tr style='background: #ffb300;'><td><strong>First Name:</strong> $name</td>
                <tr style='background: #fafafa;'><td><strong>Email:</strong> $email</td>
                <tr style='background: #fafafa;'><td><strong>Phone:</strong> $phone</td>
                <tr style='background: #fafafa;'><td><strong>Reason for Contact:</strong> $meeting_type</td>
                <tr style='background: #fafafa;'><td><strong>Best Time to Contact:</strong> $time </td>   
                <tr style='background: #fafafa;'><td><strong>Comments:</strong> $message</td>
            </table>   
            </body> 
            </html> ";
    $message = $v1; 
    $headers  = "From: $from\r\n"; 
    $headers .= "Content-type: text/html\r\n"; 
    //mail($to, $subject, $message, $headers); 
    echo "Message has been sent..."; //Page RE DIRECT 
    echo $v1;
//******************************************************************************************************************************//

    $name = $_POST["name"];
    $email = $_POST["email"];
    $phone = $_POST["phone"];
    $phone = $_POST["phone"];
    $meeting_type = $_POST["meeting_type"];
    $time = $_POST["time"];
    $message = $_POST["message"];
    $subject = 'Message Confirmed!';
    $v1 = "
            <html> …
<M/> commented: Thanks :) +0
Traevel 216 Light Poster

all my code, aside from my css is pasted above

I pasted what you had in a test file, had it post to itself and indeed got some errors. Where you have things like id="email" type="text" value="email" you need to either add name="email" or change value to name if you haven't yet. But even if you did, there are two unknown variables in there $telephone on line 24 instead of $phone and $from instead of $email on line 32.

Also, you are printing the variables after the TD's which causes them to be printed outside of the table, above as it happens.

So all these

<td><strong>First Name:</strong> </td>$name

would need changing to get them to print inside the table.

But after that it prints over here.

I only tested up until the redirect line though and deleted the mail() lines, so beyond that I don't know.

Traevel 216 Light Poster

I ran a quick test, but it seems that id and name can really be the same. If I run this test form (which posts to the same page):

    <?php 
        if(isset($_POST['name'])){
            $name = $_POST['name'];
        }else{
            $name = "unknown";
        }
        echo "My name is $name";
    ?>

    <form action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?> method="post">
        Name: 
        <select id="name" name="name">
            <option value="aaa" selected>aaa</option>
            <option value="bbb">bbb</option>
            <option value="ccc">ccc</option>
        </select>
        <input type="submit">
    </form>

It will print My name is unknown if the variable is not set, if the user picks one of the names it will print My name is aaa (bbb, ccc).

The issets would go at the top, where you could still abort the script before sending mails and such.

Traevel 216 Light Poster

Not printing the variables, weird. Not really sure as to why, but I did however stumble on something about the risk of inserting a mail address like that while looking for similar issues. Does $v1 contain all the variable information if you printed it to screen instead of mailing? If not you could wrap the $_POST's with isset's to make sure they are all set properly. At least you'll figure out which ones aren't correctly set, if any.

if(isset($_POST['name'])){
    $name = $_POST['name'];
}else{
    echo "ruh roh"; 
}

Edit:
Perhaps it's somewhere in those long strings, an unescaped quote in a variable or something. You could rewrite it using the heredoc syntax to avoid all the quoting and escaping, if all else fails.

<M/> commented: hmm, interesting. +0
Traevel 216 Light Poster

They can have the same value, or be different, doesn't matter as long as you use the name for PHP's POST.

I read up a bit on it, and according to this post you can even store multiple checkboxes by giving them an array as a name. Like, if you wanted multiple timeslots they would all have the name time[] and you could collect them all in an array by using $times = $_POST['time'].

<M/> commented: Ahhhhh :P +10
Traevel 216 Light Poster

I think he means $meeting_type = $_POST["meeting_type"] as the 5th one that needs a semicolon at the end.

And I think you have to use the name attribute instead of the id for identifying the element. So if the name of the selection is meeting_type you would get 1, 2, 3 and so on in the $_POST['meeting_type'].

<M/> commented: Gracias +0
Traevel 216 Light Poster

But how will anyone know it was updated if you delete it first?

In case you meant delete or update, then

For update:

  1. Read the file line by line
  2. Manipulate the line
  3. Write back to file

For deletion:

  1. Read the file line by line
  2. Store the lines you want to keep
  3. Write those back to file

super secret shortcut for the above steps

In all seriousness though, seeing as your file isn't very big you could probably store every line in an array, manipulate/delete those and write each value back to a file, it's nothing fancy and plenty of information already exists. Especially since it's a very general question with hardly any specifics or prework.

Traevel 216 Light Poster

Well from the query results you posted it seemed like you only needed the MoveIn and MoveOut date, what you are doing now is inserting the entire row including all other values (which could also work).

If you just want the dates stored you could do this:

while($row = mysqli_fetch_array($result)){
    $values = array($row['MoveIn'],$row['MoveOut']);
    array_push($result_array,$values);
}

Then to retrieve both dates you'd have to loop over all results and for instance use $result_array[0][0] to get MoveIn and $result_array[0][1] to get MoveOut. (of course in the loop you'd substitute the first 0 with an iterator variable like $i)

If you want to store all values from your query (for instance if you need tennant number later on) you could do

while($row = mysqli_fetch_array($result)){
    array_push($result_array,$row);
}

Then you'd do the loop, same as option one, but retrieve the date values like $result_array[0]['MoveIn'] and $result_array[0]['MoveOut']. (same as before, in the loop first 0 becomes an iterator variable)

The $arr in my first example is now the $result_array in this example.

On a sidenote, it's common practice to either go with mysqli or PDO instead of the old mysql API to connect to your database.

Traevel 216 Light Poster

You can use the DateTime::diff() function to get a DateInterval object which contains the time difference in properties.

For example:

$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);

would get you a difference object in $interval. In order to get the days you would call the intervals format function. Something like $interval->format('%d days'); to get 2 days as a result.

For the second part of getting the begin and end dates you could do something along the lines of

$arr[0] = array("2012-12-28","2013-04-13");
$arr[1] = array("2013-05-01","2014-09-30");
$arr[2] = array("2014-10-03",NULL);

$it = 0;
while($it<count($arr)){

    // if neither begin and end are NULL 
    if($arr[$it][1]!= null & $arr[$it+1][0]!=null){

        $datetime1 = new DateTime($arr[$it][1]);
        $datetime2 = new DateTime($arr[$it+1][0]);

        $diff = $datetime1->diff($datetime2);

        echo "Difference between ".$datetime1->format("Y-m-d")." and ".$datetime2->format("Y-m-d")." = " . $diff->format("%d days") . "<br/>";

    }
    $it++;
}

which will print

//Difference between 2013-04-13 and 2013-05-01 = 18 days
//Difference between 2014-09-30 and 2014-10-03 = 3 days

Note that for edge cases (i.e. begin or end is NULL or end lies before begin) the difference will not be calculated correctly so you'll want to alter this snippet to better reflect that. For instance if the end date is NULL you could substitute that with today's date.

Traevel 216 Light Poster

That's because Contains checks for an exact occurrence of the substring. I'm not very familiar with VB.NET so I'm sure there are better solutions out there than the ones I'm posting, especially length and time wise. But the problem itself could be solved in several ways (not a complete list nor in any particular order):

  • Sort both numerical strings, then compare
  • Count the numbers 0-9 in n1 and again for n2 and see if the amounts match

For non numbers as well:

  • Split both and iterate over all characters, check if a character from n1 occurs in n2, if it does remove from both arrays, if you have residual characters in either the strings do not match
  • Similarly you could take n1, iterate over each character and remove a single occurrence of that character from n2, if n2 has characters left it is not a match

By checking for edge cases beforehand you can shorten the running time of whichever method you decide to pick. Check for null and empty strings. If the strings are not the same length they can't match. If you do numeric operations have it return on a conversion error (i.e. String is not a number).

You can use these 30 String operations as a reference on how to do some of the above.

Similar reference for sorting in VB.NET.

ddanbe commented: Nice! +15
Traevel 216 Light Poster

It's working fine here. I can however reproduce that exact print by renaming the php file to html. PHP code can't be inserted into an html file, you'll have to make it a php file instead (in other words, rename it so the file ends on .php).

Keep in mind that php files need to be run on a server. An easily configurable one like XAMPP for instance.

Traevel 216 Light Poster

If you just reinstalled and you think there's something on it then reinstall again.

If by "something called Crypto" you mean CryptoLocker then the key that was used to encrypt your files may have been recovered during Operation Tovar. You can check the FireEye and Fox-IT page for instructions on getting the key that was used to encrypt your files.

But if it's all the same to you; wiping, reinstalling and not downloading anything fishy is your safest option.

Traevel 216 Light Poster

If you could slide several at a time, as if it were a single image, I'd suggest using twitter bootstrap and its carousel; never been easier.

If you need multiple images sliding one at a time there are several jQuery plugins you could use, for instance jCarousel which lets you set the number of elements.

Traevel 216 Light Poster

Passwords shouldn't be stored in the database at all, nor should it be allowed to check if passwords exist.

Usernames are a different story. You could check your db for the entered name (triggered on focus lost or something) and warn the user that the name is taken. The only way of being 100% sure there is only one username is by enforcing a UNIQUE key on the table and catching the exception if the entry is not unique. Otherwise it could still be possible to get a duplicate in, for instance inbetween the check and the actual entry.

Traevel 216 Light Poster

You could use max() to set a bottom limit of 0.

$tplaunch = max(0,($tplaunch - $tpsold));

Traevel 216 Light Poster

EF is Entity Framework, and on top of that tutorial page it does say:

Code features in this tutorial: Entity Framework Code First

In the part where you create a new cart item, did the following give you problems?

Product = _db.Products.SingleOrDefault(
           p => p.ProductID == id),

Because that should add the product as a reference to the cartitem, you would then be able to refer to product price/name as cartItem.Product.Price or cartItem.Product.ProductPrice depending on whatever it's called in the class (and/or database).

The code in the tutorial is based on earlier tutorials according to this:

Earlier in this tutorial series, you added pages and code to view product data from a database.

So the code is written based on the assumption that you are getting your information from a database. In other words, it might be trying to find your new columns in a database that was created in an earlier tutorial, since you are using the context class _db. Even if the data is from dummy info, it is still trying to save the information into a database via the context. If the class CartItem you made does not match the CartItem in the database (where it's trying to store your cartitem in the cartitem(s) table) it will throw an error, since you're trying to store data it can't fit in anywhere. The product has a price and name, but cartitem does not, it only has a product.

Again, this is based on …

PsychicTide commented: Thank you for the insight! +4
Traevel 216 Light Poster

You could use System.out.format to achieve that result. It requires a format string and variables.

A format string is built up as follows.

String contentFormat = "%-15s %-8d %-15s %n";

In the %-15s for instance: a % indicates a new "column". The - means that writing starts from the left, the 15 means it will have a total of 15 characters in width which it will try to fill with your data, the s means that the input type will be a string. It's the same for %-8d with the difference being the d which stands for digit. The %n is a newline). The spaces (or any other characters) you put in will be printed normally. So in this case you have a "column" for strings that is 15 characters in width, then a whitespace, then an 8 character wide column for digits, another whitespace, then a 15 width string again, followed by a space, then a newline.

For the actual print command you would then use something like:

 System.out.format(contentFormat, "A", 1, "$9,00");

First part is the format string variable, the other parameters are your values (they must be in the same type and order as specified in the format string, also the total amount of variables must be the same as in the format string).

Since your title has different types of variables you could write two different formats, one for the title and one for the content. Something like:

String contentFormat = …
DawnofanewEra commented: Exactly +0
Traevel 216 Light Poster

It's working fine here, after adding

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

above your script. Did you include jQuery on your page?

The $.trim() method is working as well, I get the alert when leaving the field blank and also after entering a series of whitespaces.

Word of warning, if you were to move your script to the header of the page (in other words, place the button below the script) the handler will not bind because the element doesn't exist yet at the time of execution. In that case you'd have to make sure the document is ready.

Traevel 216 Light Poster

Not familiar with the game, but it sounds fun. If you're not feeling at home with java perhaps try a simple solution first, like heading towards the one with the highest calories. Once that works you can implement better solutions.

I noticed on the video that whenever a food item gets eaten a new one pops up randomly. There are some things that come to mind after watching, maybe they'll be of help.

Keep track of your opponent, where he is and how fast he is going. Which food items can you reach before he could. Perhaps there are clusters of food items, those would be favorable over a lone (distant) single item. But what if it's a close one, or the last one in the cluster. Maybe plan ahead as well, how will an item affect my speed, will the move limit be hit before I reach it. If my opponent is lower in energy than I am perhaps I should follow a different strategy than when he is higher. If he's higher he's also slower, perhaps I can steal some food items away from a cluster he's heading to.

I guess you can make it as complex as you'd like, but I'd still start simple and build from there. From what I saw you need to implement a move() method that has a list of items/players with their coords and energy. I'd start by making some helper methods that you'll need often. One that calculates the distance to …

Traevel 216 Light Poster

Well that depends on what you want to achieve. Create an empty constructor (which will leave you with the possibility of workers that have no information) or supply values when creating the instance, for instance dummy/default values until a user has had a chance to provide the information. Or you could store the information the user provides in variables and not create a Worker instance until all the information is present (and depending on the assignment, valid).

Traevel 216 Light Poster

If you are using an IDE like Eclipse or Netbeans you can see that, by simply hovering over line 68, the error reads "The constructor Worker() is undefined". It means that you do not have an empty constructor in your Worker class. You only have one that requires paramaters: public Worker(int h, double r, String name, String title).

Traevel 216 Light Poster

document.getElementById('txtMenuInfo').innerHTML=txt; and <div id="textMenuInfo"></div>
are not the same element, change one or the other

t="<td>"</td>";
should not contain the middle "
t="<td></td>";

var text,x,xx,i; should be var txt,x,xx,i;
and
txt=text+ "</tr>"; should be txt=txt+ "</tr>";

for(i=o;i<x.length;i++) should be a 0 so for(i=0;i<x.length;i++)

x=xmlhttp.responseXML.documentElement.getElementsbyTagName("food");
should have a capital B in getElementsByTagName
x=xmlhttp.responseXML.documentElement.getElementsByTagName("food");

xmlhttp.open("GET",url,true); and xmlhttp.send(); both need to be placed outside of the function xmlhttp.onreadystatechange=function()

so

xmlhttp.onreadystatechange=function(){
    //bla
}
//xmlhttp.open("GET",url,true);
//xmlhttp.send();

If it's still not working then make sure you're running it from a server (localhost).

Traevel 216 Light Poster

Well at first glance, in insert into deals (dealname,productid) you are using dealname and not deal_name. Also, where you are using SELECT productid FROM products WHERE productid = '".$id."'"); you are twice referring to a column productid while the table products only has id, according to your description of the table layout.

Also, it could be that you are passing $productid as text and not as a number because of the single quotes. Similar problem with $id and $idd (which you are also comparing to id instead of Id by the way).

You could try printing the results of mysql_query to see whether the query fails or not. If you have access to the database itself via a console or phpmyadmin for instance you could test the queries using some default values. That way you'll be sure the queries themselves are valid, and whether or not the column/table names are indeed correct, before debugging the code.

Traevel 216 Light Poster

Hi,

It's actually just an extension to your new queue length print. If the current line length is bigger than the current max it becomes the new max. Once all the customers are done you print it where you already are printing it; outside the loop.

Traevel 216 Light Poster

Hi,

If what you mean is how you can dynamically change the image size with javascript, try something like this:

function changeImgSize(id,width,height){
    var em = document.getElementById(id);
    if (em && em.style){
        em.style.width=width;
        em.style.height=height;
    }
}

Which you would call with something like changeImgSize('imgID,400,400').

Traevel

ratanji commented: thanx alot Traevel +1
Traevel 216 Light Poster

Hi,

According to http://php.net/manual/en/function.md5.php

Returns the hash as a 32-character hexadecimal number.

The number in the confirmation e-mail is 32 characters, the number above it is not, so I'm guessing the correct one is in the e-mail and the code you have circled is not.

I was reading up on this more out of interest since I'm a bit unfamiliar with password verification, but it seems to me the error could be in a different part of the code, like the storing or the verification parts.

Not much help I'm afraid,

Traevel

Traevel 216 Light Poster

Hi,

If I am understanding it correctly you only want the ordered products to show up in your shoppingBox. However, by hard coding all the products, names and print results referring to them will be cumbersome.

Firstly, your array quant misses the first element (0) and has an eleventh element (10) instead. This will cause your loops to fail at finding the first element because you start the iterator at 0 (which is correct).

So rewriting the first array as such will solve that issue, and fix the array so that there are no empty elements.

var quant = new Array (10);
    quant[0] = Number(getInput("prodA"));
    quant[1] = Number(getInput("prodB"));
    quant[2] = Number(getInput("prodC"));
    quant[3] = Number(getInput("prodD"));
    quant[4] = Number(getInput("prodE"));
    quant[5] = Number(getInput("prodF"));
    quant[6] = Number(getInput("prodG"));
    quant[7] = Number(getInput("prodH"));
    quant[8] = Number(getInput("prodI"));
    quant[9] = Number(getInput("prodJ"));

Secondly, your name array is unused and instead you added hardcoded names. So rewrite:

var nameArray = new Array (name1, name2, name3, name4, name5, name6, name7, name8, name9, name10);
var name1 = 'prodA';
var name2 = 'prodB';
var name3 = 'prodC';
var name4 = 'prodD';
var name5 = 'prodE';
var name6 = 'prodFi';
var name7 = 'prodG';
var name8 = 'prodH';
var name9 = 'prodI';
var name10 = 'prodJ';

To:

var nameArray = new Array ('prodA', 'prodB', 'prodC', 'prodD', 'prodE', 'prodF', 'prodG', 'prodH', 'prodI', 'prodJ');

The for loop is correct, but you could rewrite it to a for ... in ... loop. That way you won't have to change the code if …

kat* commented: brilliant! +0
Traevel 216 Light Poster

Hi there,

While testing the form you described I found typing with such alterations to be extremely annoying, but here goes :P

var col = 4; //number of 'cells' in a row
var current;
var next;
document.onkeydown = check;
function check(e){
	if (!e) var e = window.event;
		(e.keyCode) ? key = e.keyCode : key = e.which;
	var num = document.getElementById("Table").getElementsByTagName("input").length;
	try{
		switch(key){
			case 37: next = current - 1; break; 		//left
			case 38: next = current - col; break; 		//up
			case 39: next = (1*current) + 1; break; 	//right
			case 40: next = (1*current) + col; break; 	//down
		}
		if (key==37|key==38|key==39|key==40){
			/* Submit etc.*/
			var code=document.forms['Table'].elements['c' + current].value;
			if(code!=""){alert(code);}
			document.forms['Table'].elements['c' + next].focus();
			current = next;
		}		
	}catch(Exception){}
}
function setCurrent(element){
	var string = element.id;
	current = string.slice(1,string.length);
}

With some HTML to test...

<form id="Table" name="Table" onKeyPress="javascript:check">
	<input id="c1" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c2" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c3" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c4" onClick="setCurrent(this);" type="text" value=""/><br>
	<input id="c5" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c6" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c7" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c8" onClick="setCurrent(this);" type="text" value=""/><br>
	<input id="c9" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c10" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c11" onClick="setCurrent(this);" type="text" value=""/>
	<input id="c12" onClick="setCurrent(this);" type="text" value=""/><br>
</form>

I wasn't really sure if something like this is what you meant, but it should work in the latest FF and IE, although I haven't tested it as much as I should have :$. Still, I hope this helps a little.

Good luck,

Traevel

haggis-man commented: Excellent - many thanks +1
Traevel 216 Light Poster

Hi there,

This might not solve your problem right away, but it might prevent some issues in the future (especially if you're copying your code over and over).

On lines 11 and 18 of your HTML code you are using cellpadding and cellspacing, but neither one is a valid CSS property. Instead you could place them outside the style tag to get the desired effect.

<table cellpadding="0" cellspacing="0" style="width: 780px; margin-top: 40px; border: 1px solid;">

Furthermore, it is best not to place properties like height, width, margin etc. in the element itself, but in a box model. Perhaps this page might be of some help.

At first I thought your problem had something to do with the differences between IE and FF, but after reading again I noticed you mentioned differences between identical pages within the same browser. Personally, I haven't spotted any errors in layout in IE or FF with your code, other than the absence of the images of course. Perhaps the following changes in the code might solve it, although I'm not exactly sure.

The new HTML now uses a div as "container" instead of the entire body. The CSS has been changed to maintain layout. One last note: since your code did not handle the "cellpadding" and "cellspacing" correctly, you might see some differences in table-layout. Just remove them if you'd wish to return to the previous look.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> …
mr_scooby commented: awesome feedback +2
Traevel 216 Light Poster

It seems that there are a lot of <BR /> tags in between your table headers (269 to be exact :-O ) starting from line 756. Deleting those tags should remove the large number of line breaks.

itsjareds commented: Good support in forums +1