Forum Moderators: open
function enter()
{
if(window.event.keyCode == 13)
{
document.forms[0].action = "results.php";
document.forms[0].submit();
}
}
-------------------------------------
when i press button, it works fine
but i want to submit the form when anyone type something in text box and when press enter.
at that time form is submited but the value of the textbox and button are not submitted. results.php file opens but does not show the php code. it shows well when i submit form using button.
i used both, forms[0] and form name('checkfrm') in javascript. but not worked in IE.
it works fine with the firefox browser but it fails in IE.
so anyone knows the remedy, then pls let me know
Thanks
-ENIL
function enterKey(e,form) {
if (window.Event) { var whichCode = e.which; } //NN
else if (e.type == "keypress") { var whichCode = e.keyCode; } // IE
else { return; }
if (whichCode == 13) { // only if enter is pressed
// Enter -only action
}
}
I say "old code" because I abandoned this method long ago. If Javascript is disabled, the enter key will still submit as if the submit button was pressed. Secondly, this is "expected behavior" for forms, many users are familiar with pressing enter to submit. You are best letting it submit to ONE script and managing it server side somehow.