insert result of Javascript function into form hidden field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Hidden

Description

insert result of Javascript function into form hidden field

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body onload="getHours()"> 
      <form method="post" action="http://example.com/some.php"> 
         <input type="hidden" name="clientid" id="clientid" value="test" action="javascript:getHours()"> 
      </form> 
      <script>
    function getHours() {//from  w ww . ja  v a2  s .c  om
        var d = new Date();
        var h = d.getHours();
        var m = d.getMinutes();
        document.getElementById('clientid').value = h + " " + m;
    }

      </script>  
   </body>
</html>

Related Tutorials