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
$(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);
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<td style="border: 1px solid black" name="column_one">
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>