www.webdeveloper.com
Results 1 to 2 of 2

Thread: Select a button by default

  1. #1
    Join Date
    Nov 2008
    Posts
    15

    Select a button by default

    Hi,

    In jsp I have added a submit button. I want to make the button as default selected. That is Just entering the 'Enter' key it should submit.
    Is that possible?

    regards,
    Jithesh PM

  2. #2
    Join Date
    Feb 2010
    Posts
    184
    use focus() on the button see the example below.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <input onclick="alert('one')" type="button" value="one" />
    <input onclick="alert('two')" type="button" value="two" />
    <input onclick="alert('three')" type="button" value="three" />
    
    <script type="text/javascript">
    	var inputs = document.getElementsByTagName('input');
    	inputs[2].focus();
    </script>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles