Code works, but HOW?

<SCRIPT TYPE="text/javascript">
<!--
var downStrokeField;
function autojump(fieldName,nextFieldName,fakeMaxLength)
{
var myForm=document.forms[document.forms.length - 1];
var myField=myForm.elements[fieldName];
myField.nextField=myForm.elements[nextFieldName];

if (myField.maxLength == null)
   myField.maxLength=fakeMaxLength;

myField.onkeydown=autojump_keyDown;
myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown()
{
this.beforeLength=this.value.length;
downStrokeField=this;
}

function autojump_keyUp()
{
if (
   (this == downStrokeField) && 
   (this.value.length > this.beforeLength) && 
   (this.value.length >= this.maxLength)
   )
   this.nextField.focus();
downStrokeField=null;
}
//-->
</SCRIPT>

</HEAD>
<BODY>
<P>Place content here.</P>
<FORM ACTION="../cgi-bin/mycgi.pl" METHOD=POST>

SSN:
<INPUT TYPE=TEXT NAME="ssn_1" MAXLENGTH=3 SIZE=3> -
<INPUT TYPE=TEXT NAME="ssn_2" MAXLENGTH=2 SIZE=2> -
<INPUT TYPE=TEXT NAME="ssn_3" MAXLENGTH=4 SIZE=4><BR>

email: <INPUT TYPE=TEXT NAME="email"><BR>

</FORM>
<SCRIPT TYPE="text/javascript">
<!--
autojump('ssn_1', 'ssn_2', 3);
autojump('ssn_2', 'ssn_3', 2);
autojump('ssn_3', 'email', 4);
//-->
</SCRIPT>

</BODY>
</HTML>

There are no events on the input boxes? When, or how, is function autojump being called?
I could understand this
<INPUT TYPE=TEXT NAME="ssn_2" MAXLENGTH=2 SIZE=2 onkeypress"(autojump...)">
LVL 2
PaullkhaAsked:
Who is Participating?
 
dakydCommented:
This section:

<SCRIPT TYPE="text/javascript">
<!--
autojump('ssn_1', 'ssn_2', 3);
autojump('ssn_2', 'ssn_3', 2);
autojump('ssn_3', 'email', 4);
//-->
</SCRIPT>

assigns the event handlers for the ssn_1, ssn_2, and ssn_3 fields.  The autojump function assigns onkeydown and onkeyup handlers to the field whose name is the first parameter.  So, for example,autojump('ssn_1', 'ssn_2', 3) assigns the onkeydown and onkeyup for ssn_1. Hope that helps.
0
 
knightEknightCommented:
here is where the event handlers are being set:

myField.onkeydown=autojump_keyDown;
myField.onkeyup=autojump_keyUp;
0
 
dakydCommented:
oops, sorry knightEknight, looks like you were quicker on the trigger.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
knightEknightCommented:
we are both right :)
0
 
PaullkhaAuthor Commented:
Damn, see it now, kewl thx
0
 
PaullkhaAuthor Commented:
In other words, the code is their, but not within view source. (Like C++ handlers)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.