Textbox Fields

Javascript, Programing Add comments

An effective way of performing script input and output operations is through use of textbox fields. You can use textboxes, as input areas into which users enter information, and you can use them as areas to display script output.

JAVASCRIPT:
  1. <script type="text/javascript">
  2.  
  3. function Assign()
  4. {
  5.   document.getElementById("OutputField").value =
  6.     "Here is the output message.";
  7. }
  8.  
  9. </script>
  10.  
  11. <input id="OutputField" type="text" style="width:200px"/>
  12. <input type="button" value="Assign Value" onclick="Assign()"/>

In a like manner, you can determine the current contents of a textbox. The following script displays the contents of the previous textbox in an accompanying area.

JAVASCRIPT:
  1. <script type="text/javascript">
  2.  
  3. function Show()
  4. {
  5.   document.getElementById("OutputArea").innerText =
  6.     "The value in the textbox is \"" +
  7.     document.getElementById("OutputField").value +
  8.     "\"";
  9. }
  10.  
  11. </script>
  12.  
  13. <input type="button" value="Show Value" onclick="Show()"/>
  14. <span id="OutputArea"></span>

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in