Easy Tutorial
❮ Jsref Regexp Charset Not Prop Submit Name ❯

Checkbox name Attribute


Definition and Usage

The name attribute sets or returns the value of the name attribute of a checkbox element.

The name attribute is used to send data to the server after form submission or to reference form data in JavaScript.

Note: Only form elements with a name attribute will have their values transmitted upon form submission.

Syntax

Set the name attribute:

Return the name attribute:


Browser Support

All major browsers support the name attribute.


Example

The following example displays the name of the checkbox:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x = document.getElementById("myCheck").name;
    alert(x);
}
</script>
</head>
<body>

<form>
<input type="checkbox" name="check1" id="myCheck">Do you like summer?
</form>
<button type="button" onclick="displayResult()">Display Name</button>

</body>
</html>

❮ Jsref Regexp Charset Not Prop Submit Name ❯