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; }); 

demo: http://jsfiddle.net/mmsfb/


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -