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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -