This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting Default Button

 
Harry Chawla
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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.
Thanks.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic