Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default button

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
0
0
US
I have many buttons on my form. How can set focus on a button so that after user enter all the info, he can hit enter and gets the form submitted?

I'm trying to do it on my body tag
<bosy onload="document.myform.mybutton.focus()">
but it doesn't seem to work.

Thanks
 
Ofcourse the button is lost focus when user clicks on other fields.

How can I hit enter & submit the form?
 
Focus should be on the suttom that was supposed to post the form, and hitting enter, the form will be submitted.
 
I know focus should be on Submit button. But how can I set focus on this button? There are many fields to enter, some of them are optional, how do I know when to set focus on the submit button???
 
I may be wrong, but when you hit Enter, it should "click" the first button within the active form. In my case, my submit button is typically the first button on any of my forms.

However, should that not be the case, then I would create a client-side function that would search to see when the Enter button is clicked and, when so, instruct that the value of your submit button is equal to true (or whatever it is supposed to be) and then submit your form. The only potential problem I see to this is if someone should hit the enter button without intending to submit your form...

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Actually, they are 5 images and one of them is to submit the form. My client does want the ability to hit enter to submit the form so I just do what she asks for. How do I fire that event? OnKeypress or something?
 
Yes, I believe it would be the OnKeyPress event. But I'm going off the top of my head here... Be forewarned...

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
It's all about the Javascript forum, forum216 -- that's where the Javascript experts hang out, which is what you're looking for, not ASP.
 
Genimuse, my original was how to submit an ASP form when user hit enter. I think this has thing to do with ASP.
 
Kendel

ASP is server-side and handling events on the server. What I believe we're talking about now is dealing with events on the client (such as when the Enter button is pressed - on the client). Ergo why Genimuse was suggesting forum216. You might find additional assistance on how to handle the OnKeyPress event in that particular forum if you are unable to obtain it here.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
My bad, thank you everyone for trying to help!

 
No problem. Hope you were/are able to resolve it. [thumbsup]

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top