focus the form element using focus()

61 views

To Focus the elements of form:
Use:
focus()

  1. <script>
  2. function foc_on_text(id)
  3. {
  4. document.getElementById(id).focus();
  5. }
  6. </script>
  7. <a href="javascript:foc_on_text(’text_name1′);">focus text1</a>  <a href="javascript:foc_on_text(’text_name2′);">focus text2</a><br>
  8. <input type="text" name="text_name1" id="text_name1" ><br>
  9. <input type="text" name="text_name2" id="text_name2">
  10.  

Demo:

focus text1  focus text2



« select all the text from form element (eg. textarea,textbox) Display And Hide Div,Span Elements or HTML Elements or Tags (Use Of style.display) »
Posted on Wednesday, April 8th, 2009 at 3:04 pm under Javascript | RSS 2.0 Feed

Post Comment

You must be logged in to post a comment.



ComputerEducationWorld.com All Rights Reserved © RSS | CBSE | Education Boards Of India | What is My IP?