javascript - Setting values of selected checkbox -
i have checkboxe dynamically appear number of times based on database. each checkbox id generated dynamically. initial value of $i 1.
<input type="checkbox" name="ch[]" id="<?php echo $i - 1;?>" />
now want set value of each selected checkbox 1 , 0 unselected checkbox in real time . plz me.
if understood correctly, set values in real time need following:
$("[name='ch[]']").on("change", function() { this.value = +this.checked; });
Comments
Post a Comment