I've found many solutions here, but have struggled trying to implement them as my form seems to be a bit more complex than most examples provided. I have a form that is populated dynamically from a DB. It pulls a list of potential services a client might select. With each service comes a checkbox to indicate if that service is selected, the unit bill associated with the service, a checkbox to indicate if that service has been adjusted, a field for the user to input the amount of the adjustment, a quantity field, and a total field. The code looks as follows:
<form method="POST" name="frmServices" action="standard_form_upda
te.asp">
<td><input type="checkbox" name="service" value="<%= rs("service_no")%>"></td>
<td><%=rs("descr")%></td>
<td><input type="text" name="quantity_<%= rs("service_no")%>" size="3"></td>
<td><input type="checkbox" name="adjusted_<%= rs("service_no") %>" value="1"></td>
<td><input type="text" name="amount_<%= rs("service_no") %>" size="6"></td>
<td><input type="hidden" id="unitbill" value="<%= rs("unit_bill")%>"></td>
<td><input type="text" name="total_<%= rs("service_no")%>" value=""</td>
I have to keep the names as is so I can match selections appropriately when I submit back to the DB. I do NOT need to submit a total for the services. I just want to have the calculation occur on the page so the user can see what the total amount will be. Also, the totaling occurs on the row, not the column. So I want to know for each service how much the bill is, not for the total of all services if that makes sense. So an example might be as follows:
Check | Service A | 5 | No Check | 0 | $5 | $25 <-- what total field should calculate
Check | Service C | 10 | Check | $2 | $5 | $20 (b/c it's adjusted, otherwise would be $5*10 units = $50)
Check | Service D | 30 | No Check | 0 | $10 | $300
So the calculation should occur whenever the first column (name="service") is checked. Otherwise the total should be blank or zero for a given service. Since the DB might pull 15 services I only need to run the calculation on whichever services are checked.
Sorry for the reduncancy, just trying to be clear. I appreciate any help you can provide.