Link to home
Start Free TrialLog in
Avatar of StewSupport
StewSupport

asked on

press enter to submit a form or equal to a click on a button in a form

i have a search box and 2 buttons on a form. what i want to do is after i type in the search box, i want to be able to hit enter and it will automatically knows button 2 is the search button because button 1 is a clear button. how do i do that. my page is in html and vbscript? thanks.
SOLUTION
Avatar of Samuel Liew
Samuel Liew
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of StewSupport
StewSupport

ASKER

yes
sorry i meant when i hit enters it will know that i want to submit the search not to reset.
The code provided above will submit the form when you press enter after filling in the textbox.
i see but if i just have submit buttons and only want one.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you mean:
I have more than one submit button and I want only one of them to submit the form?
No. What I replied was nothing to do with the submit button. I explained how to make hitting enter on any of the text fields or controls of the form to invoke submit form action, which is equivalent to hitting the subtmit button of the fomr.

Take for isntance a email accuont login screen. Type the username and perss enter, the page submits the form data. The user need not have to navigate to the submit button and press it, or use the mouse to navigate to the button and clickit.

hope this is clear
Then the code I posted in the first post will do it. Just make sure you got a form field and a submit button inside. When you hit enter anywhere in the form it will submit it.