javascript - Iterating through all selected checkboxes and get the value of input boxes in jquery -
this question has answer here:
i have code whereby in table row there checkboxes , input boxes, values of input boxes checkboxes checked
this html
<table> <tr> <td><input type="checkbox" name="new" value="37"></td> <td><input type="text" name="new" id="quantity" class="37"></td> </tr> <tr> <td><input type="checkbox" name="new" value="38"></td> <td><input type="text" name="new" id="quantity" class="38"></td> </tr> .....#this continue </table>
note class of input boxes same value of checkboxes
currently using code check checked checkboxes
var marked = new array(); var k = 0; $('input:checked').each(function(index,value) { marked[k] = value; k++; alert(k); }); alert($('input[name="new"]:checked').serialize());
how can change return value of input boxes
try this:
$(document).ready(function(){ $( "input[type=checkbox]" ).each(function(){ if($(this).is(':checked')) { var value = $(this).closest('tr').find($( "input[type=text]" )).val(); alert(value); } }); });
Comments
Post a Comment