my title may be hard to understand but i didnt know how to ask this question so let me explain. Here is my script
$(this).parent("td").siblings("td:last").text(intTotal);
This script display results inside td tag <td></td>.. How do i make the intTotal to display inside input field <input id="total"> please note i have many rows and i tried using $("#total").val(intTotal) but this can only work if i had 1 row.
Here is the rest of the script
var strClass = $(this).prop("class");
var intTotal = 1;
$.each($("input:text." + strClass), function () {
var intInputValue = parseInt($(this).val());
if (!isNaN(intInputValue))
{
intTotal = intTotal * intInputValue;
}
});
$(this).parent("td").siblings("td:last").text(intTotal);
});
Thank You
Your code below sends the results to the last element of the td.
$(this).parent("td").siblings("td:last").text(intTotal);
To assign a value inside an element using jQuery, you must first select it and then edit its content using the html(), text(), val()... functions.
In your case, the code below will update the value of the input with the #total id.
$("#total").val(intTotal);