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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make a button the default 1

Status
Not open for further replies.

scc

Programmer
Apr 30, 2001
218
US
If my web page has several buttons, how can I make one of the buttons the default button so that when the user presses the enter key, the default button is activated?

TIA!
 
I could be wrong but the default button is the button inside the form tags of that form.
 
<script language='VBScript'>
document.form1.button1.focus()
</script>


 
I don't really want it to have the focus, I just want it to be the default if more than one button exists and the user presses enter to activate the default button.

I've seen this done and trying to figure out how it was accomplished. This would be like setting a command button as the default in a VB form.
 
Make the default button a submit button
<input typ=submit name=&quot;btnname&quot; value=&quot;Submit&quot;>
and the other buttons
<input type=&quot;button&quot; name=&quot;btnName&quot; value=&quot;whatever&quot;>

By default, when the user presses enter, the submit button is the one that is activated.

 
That's exactly what I was looking for. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top