1

I have below table

<table id="grid_table">
    <tr>
        <td><input name="" value="3" id="id_3" checked="checked" type="checkbox"></td>
        <td><input name="qty[]" value="5.0000" type="text"></td> 
    </tr>
    <tr>
        <td><input name="" value="4" id="id_4" checked="checked" type="checkbox"></td>
        <td><input name="qty[]" value="2.0000" type="text"></td> 
    </tr>
</table>

Javascript

jQuery('table#grid_table input[type=input]').each( function(){  
    alert(jQuery(this).find('qty[]').val());
});

I'm able to get qty value.

How to get row wise if checkbox is checked then checkbox value & it's textbox value?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Jackson
  • 1,426
  • 3
  • 27
  • 60
  • 2
    what is `qty[]` should it be `[name=qty[]]` – guradio Mar 28 '17 at 09:26
  • There are too many questions in this topic http://stackoverflow.com/questions/17356497/get-the-table-row-data-with-a-click, http://stackoverflow.com/questions/11213335/getting-the-table-row-values-with-jquery – Pugazh Mar 28 '17 at 09:28
  • Did you see my answer? Wasn't the answer you were looking for? – Mamun Mar 30 '17 at 04:17
  • Just change it on Page Load instead of Checkbox. Then will accept it @Mamun – Jackson Mar 30 '17 at 04:52
  • I have changed the code. Please check snippet and let me know whether that works for you. – Mamun Mar 30 '17 at 05:27

1 Answers1

1

Try the following code:

$('table#grid_table tr').each( function(index, item){
   
   if($(item).find('input:checkbox').is(':checked')){ 
      var chk = $(item).find('input:checkbox').val(); 
      console.log('Checkbox value at row '+index+': '+chk);
      var txt = $(item).find("input[name='qty[]']").val();
      console.log('Textbox value at row '+index+': '+txt);
    }

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="grid_table">
    <tr>
        <td><input name="" value="3" id="id_3" checked="checked" type="checkbox"></td>
        <td><input name="qty[]" value="5.0000" type="text"></td> 
    </tr>
    <tr>
        <td><input name="" value="4" id="id_4" checked="checked" type="checkbox"></td>
        <td><input name="qty[]" value="2.0000" type="text"></td> 
    </tr>
</table>
Mamun
  • 66,969
  • 9
  • 47
  • 59