how to calculate row total in dynamic form?

Giganews Newsgroups
Subject: how to calculate row total in dynamic form?
Posted by:  Rich_C (RichCrid…@aol.com)
Date: 17 Jun 2006

I'm sure this is very simple, but I have very little experience with
javascript -- and what I do know isn't helping me here.

I have a simple form where users can enter a quantity (qty) and cost
(cost).  Users can dynamically add rows to the table so I don't know
how many rows might need to be calculated.

I need to calculate the total (qty * cost) and put that number in a
table cell (or read only input box).  I also need to sum the totals for
a grand total.

can someone point me in the right direction?

<form action="purchase_req1.asp" method="post" name="purchreq"
onsubmit="return validate();">
<table id="itemlist" width="100%">
<tr>
<td valign="top" height="15"><input type="text" name="qty"
size="4"></td>
<td valign="top" height="15"><textarea name="desc" rows="4"
cols="40"></textarea>
<td valign="top" height="15"><input type="text" name="cost"
size="6"></td>
<td valign="top" height="15">[PUT TOTAL HERE]</td>
</tr>
<tr>
<td valign="top" height="15"></td>
<td valign="top" height="15"></td>
<td valign="top" height="15"></td>
<td valign="top" height="15">[PUT GRAND TOTAL HERE]</td>
</tr>
</table>
</form>

Replies