Web Hosting Talk







View Full Version : Java Script Question


jtrovato
11-07-2002, 10:28 AM
I have a client who is lazy! Don't we all

well anyway, he wants to know if I could code my php to auto jump (tab) to the next field when it hits the end.

ie.

(516) 555 - 1212 - each one of these are in a different input field.

this is the function I use to capture then phone number



function GetPhone ($Var,$extVar)
{
echo "(<input type=text name=".$Var."1 size=3 maxlength=3>)";
echo "<input type=text name=".$Var."2 size=3 maxlength=3>-";
echo "<input type=text name=".$Var."3 size=4 maxlength=4>";
if ($extVar!="")
echo " Ext <input type=text name=".$extVar." size=5 maxlength=5>";
}


I would like to know if there is a way to have it move over to the next input field using java script so the user can just keep typing away.

Thanks for the input..

John

Studio64
11-07-2002, 10:55 AM
Using the constraints of the code given.... No...

Because all of the form inputs have the same name...

Aside from that... Even when the form is submitted I'm fairly sure all you'll get is the value of the last text feild not the total of the 3.

jtrovato
11-07-2002, 10:58 AM
You have to look at it again I get 3 different fields. this works fine, my client just wanted to know if there was a way to have it "jump" to the next field as soon as 3 chars where entered.

Does anybody know. I have seen it done on other sites but I do not remeber the site to check for myself

John

MarkIL
11-07-2002, 12:13 PM
http://www.mattkruse.com/javascript/autotab/source.html