How to identify duplicate form elements with same name in a funcation????
Hi guys,
I have multiple price and quantity fields and their total ( price * quantity) in a loop with same form name and I want to calculate the total in each row with onChange event.
Since they have same name how do I identify the exact fields. Please see example and give me a hint on how I can grab the exact changed field to calculate the corresponding total.
The grand total field is outside the loop and would be the sum of all totals
%
for (i=0; i<5; i++)
{
%>
<input type="text" name = "price"> <input type="text" name = "quantity"> <input type="text" name = "total">
<% } %>
<input type="text" name="grand_total" >
Pls guide me to correct this.
Thanks,
Riju.
Re: How to identify duplicate form elements with same name in a funcation????
Hi,
When you name/id two or more HTML elements with the same name/identifier, the corresponding JavaScript objects are put into an array of that name, so they can be handled as a group. Why use the same names? Only a few types of elements are designed to be used in groups (radio buttons, e.g.). Identifiers should be unique.
:)
Karthik