Input Checkbox name Property - Change the name of a checkbox: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox

Description

Input Checkbox name Property - Change the name of a checkbox:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

A Checkbox: <input type="checkbox" id="myCheck" name="myname">

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

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

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

</body>
</html>

Related Tutorials