Input Checkbox value Property - Change the value associated with the checkbox: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox

Description

Input Checkbox value Property - Change the value associated with the checkbox:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

A Checkbox: <input type="checkbox" id="myCheck" value="myvalue">

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

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

function change() {//from   w  w  w  .  jav a2  s .  c o  m
    var x = document.getElementById("myCheck").value = "newCheckboxValue";
    console.log("The value was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials