9
I’m trying to make a code that checks how many checkboxes are checked by clicking a button, because I’m making a system that duplicates records. I have a list with several checkboxes, and when the person clicks on the "duplicate" button jQuery will check which ones are marked and get the value of them. I have no idea how to do it, because I tried it in various ways and nothing. The last code I tried was this:
<script>
(document).ready(function(){
$("#duplicar-registro").on('click', function(){
var checkbox = $("#mcheckbox");
for(i=0;i<= checkbox.length;i++){
if($("input[id=mcheckbox]:checked") == true){
console.log(i); //Ver no console
}else{
console.log(i); //Ver no console também
}
}
})
});
</script>
I believe the example is not working!
– Voltz
@Gabrielborghi I believe that due to Jsfiddle update jQuery is not included, see here http://jsfiddle.net/UtL36/31/
– abfurlan
It doesn’t work for me, but beauty was only to be sure in case someone needs it, but the code already helped me worth.
– Voltz