Input Hidden value Property - Change the value of the hidden field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Hidden

Description

Input Hidden value Property - Change the value of the hidden field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

A hidden input field:
<input type="hidden" id="myInput" name="country" value="Norway">

<button onclick="display()">Display value</button>
<button onclick="change()">Change value</button>

<script>
function display() {
    var x = document.getElementById("myInput").value;
    console.log("The value of the hidden input field is: " + x);
}

function change() {/*from  www . j  a  va2 s  .co m*/
    var x = document.getElementById("myInput").value="USA";
    console.log("The value was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials