G
Guest
I am trying to figure out the best way to change a form's action based
on a single text input event.
I have a search form within a larger form and would like to allow users
to use the enter key within the search text input without submitting
the larger form. I discovered the onKeyPress event and the keyCode for
the Enter Key (13). Now I need to figure out a way to pass the result
of the onKeyPress to the larger form's onSubmit event to return false
if the onKeyPress is true or allow the larger form to submit if false.
What's the easiest way to pass the onKeyPress value to the onSubmit
event?
if (event.keyCode == 13) {
document.getElementById('myform').action = "javascript: return
false;";
}
or
if (event.keyCode == 13) {
document.forms.element.hiddentextinput.value = "javascript: return
false;";
}
Thank you for your assistance.
Respectfully,
Gary
on a single text input event.
I have a search form within a larger form and would like to allow users
to use the enter key within the search text input without submitting
the larger form. I discovered the onKeyPress event and the keyCode for
the Enter Key (13). Now I need to figure out a way to pass the result
of the onKeyPress to the larger form's onSubmit event to return false
if the onKeyPress is true or allow the larger form to submit if false.
What's the easiest way to pass the onKeyPress value to the onSubmit
event?
if (event.keyCode == 13) {
document.getElementById('myform').action = "javascript: return
false;";
}
or
if (event.keyCode == 13) {
document.forms.element.hiddentextinput.value = "javascript: return
false;";
}
Thank you for your assistance.
Respectfully,
Gary