Search results

Name and Value in form submit in JavaScript (ES5) CheckBox control

17 Mar 2023 / 1 minute to read

The name attribute of the CheckBox is used to group Checkboxes. When the Checkboxes are grouped in form, the checked items value attribute will post to the server on form submit that can be retrieved through the name. The disabled and unchecked CheckBox value will not be sent to the server on form submit.

In the following code snippet, Cricket and Hockey are in the checked state, Tennis is in disabled state and Basketball is in unchecked state. Now, the value that is in checked state only be sent on form submit.

Copied to clipboard

//Name and Value attribute in form submit.
var checkbox = new ej.buttons.CheckBox({ name: 'Sport',  value: 'Cricket', label: 'Cricket', checked: true });

checkbox = new ej.buttons.CheckBox({ name: 'Sport',  value: 'Hockey', label: 'Hockey', checked: true });

checkbox = new ej.buttons.CheckBox({ name: 'Sport',  value: 'Tennis', label: 'Tennis', disabled: true });

checkbox = new ej.buttons.CheckBox({ name: 'Sport',  value: 'Basketball', label: 'Basketball' });

var button = new ej.buttons.Button({ isPrimary: true });
Copied to clipboard
<!DOCTYPE html><html lang="en"><head>
    <title>EJ2 CheckBox</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="//" rel="stylesheet">
    <link href="//" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
<script src="" type="text/javascript"></script>

    <div id="container">
                <li><input type="checkbox" id="checkbox1"></li>
                <li><input type="checkbox" id="checkbox2"></li>
                <li><input type="checkbox" id="checkbox3"></li>
                <li><input type="checkbox" id="checkbox4"></li>
                <li><button id="btnElement">Submit</button></li>

var ele = document.getElementById('container');
if(ele) { = "visible";
<script src="index.js" type="text/javascript"></script>
Copied to clipboard
#container {
    visibility: hidden;

#loader {
  color: #008cff;
  height: 40px;
  width: 30%;
  position: absolute;
  top: 45%;
  left: 45%;

.e-checkbox-wrapper {
  margin-top: 18px;

button {
  margin: 20px 0 0 5px;

li {
  list-style: none;