Entry
When a form has a single input text field and several submit buttons, how can I set the default button when Enter is pressed?
Apr 20th, 2000 04:31
Martin Honnen, Anthony Howe,
You don't even need a submit button to get a single text field form
submitted, thus there is no submit button associated with pressing
enter. That is just another way of submitting a form. If you want to
associate a submit button with the enter key use key event handling:
<FORM NAME="formName">
<INPUT TYPE="text" NAME="aField" VALUE="Kibology"
ONKEYDOWN="if ((event.which && event.which == 13)
|| (event.keyCode && event.keyCode == 13)) {
this.form.submit0.click();
return false;
}
else return true;"
>
<INPUT TYPE="submit" NAME="submit0" VALUE="Kibo">
<INPUT TYPE="submit" NAME="submit1" VALUE="Maho">
</FORM>