Javascript/JQuery iterate through table rows and cells and output an attr of checked checkboxes to console -


i have following code, should go through each table row , dump array declared in earlier segment of javascript. if checkbox checked, , has attr of "changed=yes" should pushed onto array , value should outputted in console "path" attribute should outputted variable can overwritten every time function finds new checkbox checked , changed. wrong code? these functions contained in function called when user clicks submit on form.

jsfiddle: http://jsfiddle.net/hu89p/392/

        $('#mytable1 tr').each(function(){         myarray = [];                     $.each($("input[type='checkbox']:checked").closest("td").siblings("td"),                     function () {                     if($(this).data("changed") == 'yes'){                         myarray.push($(this).attr('checkboxtype'));                         filepath = $(this).attr('path');                         console.log(myarray);                         console.log(filepath);                     }                 });             }); 

here working fiddle :

keep simple :

$('#mytable1 tr').each(function() {        var columns = $(this).find('td');         columns.each(function() {            var box = $(this).find('input:checkbox');             if(box.is(":checked") && box.attr("changed") == 'yes')            {                 myarray.push(box.attr('checkboxtype'));                 filepath = box.attr('path');                                         }         });     });          console.log(myarray);   }); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -