samedi 14 novembre 2015

loop through html table and check if a checkbox is checked or not

what im trying to do here is validating html table. i need at least one checkbox to be checked before proceding. it's doing what it's need to do. but when i didn't checked a checkbox. it loops the alert nothing found by the count of data on the html table. how to make it better? but i need to loop inside the table to get the data on the same row with the checkbox checked this is the javascript code.

  $('#dataTable').find('tr').each(function () {
                    var row = $(this);
                    if (row.find('input[type="checkbox"]').is(':checked') ) {
                        alert "found"
//im getting data here.
                        });
                    }else{
                        alert "NOthing found"
                    };
                });




Aucun commentaire:

Enregistrer un commentaire