Martin <> wrote in
news::
> Is there any way (using javascript) to "click" a specific "submit"
> button when the user hits the <Enter> key?
>
> From what I read, hitting <Enter> is supposed to send the form via the
> "first" submit button on the page but I find that, in IE at least, my
> server-side scripting doesn't receive any submit button.
I'm not sure about pre-picking a particular button, but why not just use
the same event handler for your default button AND the return key?
In the example, "dh" is the default form handler, which will execute if
button yy is pushed, or if the return key is pressed. "hh" will only be
called if button xx is pressed.
You can also designate other functions to fire when any particular key is
pressed, just by changing the value of 13.
<form name="myform" action="" method="post">
<input title="tt" type="text" name="inputbox" value="ib" maxLength="10"
size="10" onkeypress="if (event.keyCode==13) {dh(this.form);};" >
<input type="button" name="button" value="xx" onClick="hh(this.form);" >
<input type="button" name="button" value="yy" onClick="dh(this.form);" >
</form>
|