Search results

Name and Value in form submit

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.

Source
Preview
index.js
index.html
styles.css
ej.base.enableRipple(true);

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

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

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

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

var button = new ej.buttons.Button({ isPrimary: true });
button.appendTo('#btnElement');
<!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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet">
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
        <form>
            <ul>
                <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>
            </ul>
        </form>
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>
#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;
}