JAVASCRIPT
get all values checked checkboxes jquery
var selected = []; // New array
$("#inputID input[type=checkbox]:checked").each(function () {
selected.push(this.value);
});
jquery get all checked checkboxes
var values=[];
$('input[name="your-checkbox-name[]"]:checked').each(function () {
values[values.length] = (this.checked ? $(this).val() : "");
});
select all checkboxes jquery
$('input:checkbox').prop('checked', true);
jquery validate all checkbox checked
<form id="form1" action="/controller/action" method="post">
<input type="checkbox" name="box1" class="cBox" />
<input type="checkbox" name="box2" class="cBox" />
<input type="checkbox" name="box3" class="cBox" />
<input type="submit" value="Submit" />
</form>
<script>
$('#form1').submit(function() {
if ($('input:checkbox', this).length == $('input:checked', this).length ) {
// everything's fine...
} else {
alert('Please tick all checkboxes!');
return false;
}
});
</script>
jquery get all checkbox checked
$('.theClass:checkbox:checked')
select all checkbox jquery
$('#select_all').change(function() {
var checkboxes = $(this).closest('form').find(':checkbox');
checkboxes.prop('checked', $(this).is(':checked'));
});
find all checkbox inside div jquery
$('#selectChb').click(function(){
$(':checkbox').prop("checked", true);
});
jquery select all checkboxes
//html
<input type="checkbox" onclick="CheckAll(this)" id="checkboxAll" title="Select All" />
//jquery
function CheckAll(elem) {
$('[name="checkbox"]').prop("checked", $(elem).prop('checked'));
}
select all checkbox jquery
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form>
<table>
<tr>
<td><input type="checkbox" id="select_all" /></td>
</tr>
<tr>
<td><input type="checkbox" name="select[]" /></td>
</tr>
<tr>
<td><input type="checkbox" name="select[]" /></td>
</tr>
<tr>
<td><input type="checkbox" name="select[]" /></td>
</tr>
</table>
</form>