Update textfield value by function - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Update textfield value by function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// www  .  j  a va  2  s .c o m
function UpdateField(name, val)
{
      var fieldId = "pv-" + name;
      document.getElementById(fieldId).value = val;
}
UpdateField("field1", "a");
UpdateField("field2", "b");
UpdateField("field3", "c");
    }

      </script> 
   </head> 
   <body> 
      <input id="pv-field1"> 
      <input id="pv-field2"> 
      <input id="pv-field3">  
   </body>
</html>

Related Tutorials