File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes setting Default Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "setting Default Button" Watch "setting Default Button" New topic

setting Default Button

Harry Chawla
Ranch Hand

Joined: Jun 03, 2000
Posts: 97
I was wondering if i can set a default button on my web page using Javascript or DHTML.
Any suggestions will be highly appreciated.
Thanks Bill for keeping it going.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
There are two things you can do that I can think of. First is to setFocus on the button that you want to be the default, if you want to give it focus. Or if you are saying you want a certain button to respond with the enter key, like a default button, then you would need to capture the enter key and activate any function the button would have on the enter key.
What are you trying to do, have a form with two buttons like a reset and submit, but you want the submit button to be the default and not the reset?
I haven't looked too much into this, so there are probably better solutions that I have shown here. I'll try to look up some more when I get a chance.
I agree. Here's the link:
subject: setting Default Button
jQuery in Action, 3rd edition