Input Checkbox value Property - Submitting a form, how to change the value associated with the checkbox: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox

Description

Input Checkbox value Property - Submitting a form, how to change the value associated with the checkbox:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
  <input type="checkbox" id="myCheck" name="vehicle" value="Happy" checked>How are you today<br>
  <input type="submit" value="Submit">
</form>//from  ww w .jav a2 s . co m

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myCheck").value = "newCheckboxValue";
    document.getElementById("demo").innerHTML = "attribute was changed.";
}
</script>

</body>
</html>

Related Tutorials