Javascript Form How to - Set hidden element value








Question

We would like to know how to set hidden element value.

Answer


<!--   w  w  w. j a v a  2  s .c  o  m-->
<html>
    <body>
    <form name="form1">
    Form name:<input type="hidden" name="hide1" value="Test">
    <P>
    <input type="button" value="Form Name"
       onClick="this.form.hide1.value=this.form.name">
    </form>
    </body>
</html>

The code above is rendered as follows: