When my page opens then all the checkboxes are checked by default and while submitting the form, I am not able to get the value of the checked checkboxes in a array. The user may not click the checkboxes as it is by default all checked. So I tried to receive the checked value using:
var valores = (function() {
var valor = [];
$('input.className[type=checkbox]').each(function() {
if (this.checked)
valor.push($(this).val());
});
return valor;
})();
console.log(valores);
My codes for the checkboxes is:
<div class="form-group" id="documents">
<label> <input id="check_id3" type="checkbox" value="3" class="chk3" checked=""> <span>OTHERS</span>
<br>
</label>
<div style="padding-bottom:5px"></div>
<label> <input id="check_id1" type="checkbox" value="1" class="chk1" checked=""> <span>Invoice</span>
<br>
</label>
<div style="padding-bottom:5px"></div>
<label> <input id="check_id2" type="checkbox" value="2" class="chk2" checked=""> <span>Packing List</span>
<br>
</label>
<div style="padding-bottom:5px"></div>
</div>