select all the text from form element (eg. textarea,textbox)

63 views

To select content or text from form element:

use:

select();

Example:

  1. <script>
  2. function all_select_content()
  3. {
  4. document.getElementById(’select_all_content’).select();
  5. }
  6. </script>
  7. <textarea id="select_all_content" rows="5" cols="30">Select content from textarea just click the botton below.</textarea>
  8. <input type="button" name="button" value="Select all" onclick="all_select_content()">
  9.  

Demo:



« what is the other method we can use, when we are not using form name ( getElementById() ) in Javascript? focus the form element using focus() »
Posted on Wednesday, April 8th, 2009 at 1:53 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?