javascript - Two event in a single jsp tag -
i want make search button work on hitting enter button on click on button. tried below code
search:
<input id="search" type="text"> <input type="button"id="btn" value="search" onkeypress="submitonenter(this,jquery.event);" onclick="query()" /> <script type="text/javascript"> function submitonenter(inputelement, event) { if (event.keycode == 13) { inputelement.form.submit(); } } </script> but not able make enter button searchable. onclick working fine
try this
document.onkeypress = function keypressed(e){ if (e.keycode == 13) { document.forms['formname'].submit(); } }
Comments
Post a Comment