Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onfocus() and onKeyUp

Status
Not open for further replies.

DeSn

Programmer
Nov 20, 2001
111
0
0
BE
Hi,

The following code works fine in IE but doesn't work in Netscape (4.79). I don't know if it is the onfocus or the onKeyUp that doesn't work.

<input name="vanA" class="textbox" type="text" size="1" style="width=20px" onKeyUp="javascript:alert(this.value.length);if(this.value.length>=2){vanB.focus();}">
/<input name="vanB" class="textbox" type="text" size="1" style="width=20px" onKeyUp="javascript:if(this.value.length>=2){vanC.focus();}">

Can anyone help me?
 
What you could do is test one (using a cut-down page with just, say, onKeyUp) and test the other (with just onFocus)... that way you can answer your own question of which one doesn't work (or confirm that both don't).

Then you could go to Google and do a search with the name of the browser, the word "problem" and name of the function that you don't see supported in the input tag.

I find this technique works for almost every single post on this forum.

Jeff
 
The "focus()" method is the problem, but I can't find a solution :(
 
You may need to more fully qualify your object references.

Some browsers may not know what "vanB" or "vanC" is. Try referencing the objects beginning at the "document." level...

To test, try something like:

onKeyUp="if(this.value.length>=2){alert(typeof vanC);}"

...and see if "vanC" ends up being "undefined". If so, then your browser is unable to resolve the simple "vanC" reference. Be more specific.

Also note that, for onKeyUp and other events, the "javascript:" lead-in is unnecessary. The "javascript:" start is usually only needed for <a>nchor-tag href= code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top