Dear all,
I am trying to get enter key event in netscape 7.0.
( This is not php issue and maybe this is off topic here. You can ignore this topic. I am sorry. )
Please feel free to copy and try this. It works in both IE and Netscape. I want like this in my php and so I save it as test.php. Whenever I press Return/Enter key in Netscape, key press event causes submitting form instead of going to next input text box. Anybody help me out. Thanks.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
nextfield = "box1"; // name of first box on page
netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");
function keyDown(DnEvents) { // determines whether Netscape or Internet Explorer
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k == 13) { // enter key pressed
if (nextfield == 'done') return true; // submit, we finished all fields
else { // we're not done yet, send focus to next box
eval('document.yourform.' + nextfield + '.focus()');
return false;
}
}
}
document.onkeydown = keyDown;
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);
// End -->
</script>
</HEAD>
<BODY>
<center>
<form name=yourform>
Box 1: <input type=text name=box1 onFocus="nextfield ='box2';"><br>
Box 2: <input type=text name=box2 onFocus="nextfield ='box3';"><br>
Box 3: <input type=text name=box3 onFocus="nextfield ='box4';"><br>
Box 4: <input type=text name=box4 onFocus="nextfield ='done';"><br>
<input type=submit name=done value="Submit">
</form>
</center>
</BODY>
</HTML>