I'm trying to select the current row <td>
tag input value, when check box is selected for that particular row, but it returns null
.
I've tried to fetch the current row and I got it to read the value of input box of the selected checkbox row
var allVals = [];
$('input[name=selectedBilties]:checked').each(function() {
var freight_id = $(this).closest('tr').find( $('input[name="freight_id[]"]') ).val();
allVals.push($(this).val());
allVals.push(freight_id);
});
console.log("All Values"+ allVals);
html table with php->codeigniter
<table id="example1" class="table table-bordered table-striped table-sm" style=" overflow: auto; ">
<thead class="bg-info">
<tr>
<th>Select</th>
<th>Bilty No</th>
<th>Bilty Date</th>
<th>Pkgs</th>
<th>weight</th>
<th>From</th>
<th>TO</th>
<th>Consignor</th>
<th>Consignee</th>
<th>Remark</th>
</tr>
</thead>
<tbody class="table-hover">
<?php foreach($crossing as $pod){?>
<tr>
<td><input type="checkbox" id="selectedBilties" name="selectedBilties" value="<?php echo $pod->id;?>"></td>
<td><?php echo $pod->id;?></td>
<td><?php echo $pod->lr_date;?></td>
<td><?php echo $pod->no_of_pkgs;?></td>
<td><?php echo $pod->lr_actual_weight;?></td>
<td><?php echo $pod->lr_from;?></td>
<td><?php echo $pod->lr_to;?></td>
<td><?php echo $pod->consignor_name;?></td>
<td><?php echo $pod->consignee_name;?></td>
<td><?php echo $pod->lr_description;?></td>
<input class="selected" type="text" id="freight_id" name="freight_id[]" value="<?php echo $pod->fr_memo_ids; ?>">
<input class="selected" type="hidden" id="challan_id" name="challan_id[]" value="<?php echo $pod->challan_id; ?>">
</tr>
<?php }?>
</tbody>
</table>