i got input goes this
<input type="number" min="0" name="quantity'.$read['id'].'" value="0" placeholder="something" /> <input type="checkbox" name="productid[]" /> how can check checkbox if value of number goes more 0 multiple checkboxes , inputs
if understand goal correctly, have multiple numbered pairs of number , checkbox input, without properties of linking them. best linking them through attribute/class/code/etc, if pairing can done number followed checkbox, can use .next checkbox following changed input:
$('input[type=number]').change(function(){ if(this.value > 0) $(this).next('input[type=checkbox]')[0].checked=true; }); this monitors change on input of type number, checks value (this) , set nearest input of type checkbox checked.
edit
to check , uncheck if can skipped , used directly value being set:
$('input[type=number]').change(function(){ $(this).next('input[type=checkbox]')[0].checked= this.value > 0; });
Comments
Post a Comment