This is my table image that i have fetched from the another table in this table i am doing some calculation using javascript.When i tried to change the qty value,it should multiply with rate and show it in the total. My problem when i change the value the both rows of the total shows same result.
My code:
<script type="text/javascript">
function calculate(id){
var tot = 0;
var qty = document.getElementsByClassName("qty");
var rate = document.getElementsByClassName("rate");
var total = document.getElementsByClassName("total");
for(var i = 0; i < qty.length; i++)
{
tot = parseFloat(qty[i].value) * parseFloat(rate[i].value);
$(".total").val(tot);
}
}
</script>


$(".total").val(tot);modifies EVERY element of class total. Try$(".total").eq(i).val(tot);$(".total")[i].val(tot)wont work as$(".total")[i]is getting the underlying DOM object therefore it doesnt have aval()method that is a jquery method