Level 75
Try getting via index:
Just quick example
var $td = $(this).closest('tr').children('td');
var tid = $td.eq(0).text();
Another td would be
$td.eq(index you need)
like
var tdescribe = $td.eq(2).text();
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a total of three columns in the table, in the first column I have retrieved the information from the database, in the second column there is an input field where the first column will be added to the information I will give and it will be displayed in the third column.
I have followed the below methods but the results are always coming NaN.
this is my html code
<td style="border: 1px solid black" name="column_one">{{ $p_report->column_one }}</td>
<td style="border: 1px solid black"><input type="text" name="column_two" class="form-control"></td>
<td style="border: 1px solid black" class="" name="column_five"></td>
this is my jquery code
$(document).ready(function (){
$('[name=column_two]').on('change', function (i){
if(i==0) return true;
var tr = $(this).closest('tr');
var column_one = parseFloat($('[name=column_one]', tr).text());
var column_two = parseFloat($('[name=column_two]', tr).text());
$('[name=column_five]').text(column_one + column_two);
})
});
I'm new so I can't solve it. Please help me.
Try getting via index:
Just quick example
var $td = $(this).closest('tr').children('td');
var tid = $td.eq(0).text();
Another td would be
$td.eq(index you need)
like
var tdescribe = $td.eq(2).text();
Please or to participate in this conversation.