what is the other method we can use, when we are not using form name ( getElementById() ) in Javascript?

28 views

We can use a javascript function getElementById() in place of form name.

Example:

  1. <script>
  2. function use_of_getelement()
  3. {
  4. var text = document.getElementById(‘text_box_text’).value;
  5. alert("you have written "+text);
  6. }
  7. </script>
  8. <input id="text_box_text" type="text" value="Just Write Something" />
  9.  
  10. <input onclick="use_of_getelement()" name="button" type="button" value="Show My Text" />

Demo:



« Add To Bookmark In Javascript select all the text from form element (eg. textarea,textbox) »
Posted on Wednesday, April 8th, 2009 at 12:34 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?