Click to See Complete Forum and Search --> : Text box with same name


shanuragu
06-20-2003, 02:27 AM
Hi

I have dispalyed text boxes with same name using a while loop. But to differentiate then text box name is concatinated with the record Id.
Ex:
Name Qty UnitCost Amount are four the text boxes

based on the quantity entered amount is updated which is happening with onblur in qty field. All these processes are happening successfully. Now I want to sum up all the amount in amount field. & display that in the Total Amount Field.

function TotalCostPerCd(cdId)
{
var sum;
var qtyTxt = document.getElementById("lilaQuantity"+cdId);
var amountTxt = document.getElementById("lilaAmount"+cdId);
var ucostTxt = document.getElementById("lilaUnitCost"+cdId);
amountTxt.value=qtyTxt.value*ucostTxt.value;
}

HTML Code for the fields is as follows

<%
dim amt
cur=RsCdPrice("CdCurrency")
amt=0
While Not RsCdPrice.Eof
CId = RsCdPrice("CdTitleId")
amt=amt+RsCdPrice("CdPrice1")
%>
<tr>
<td>
<%=RsCdPrice("CdTitle")%>
</td>
<td align="center">
<input type="text" name="lilaQuantity<%=RsCdPrice ("CdTitleId")%>" size="3" value="1" onKeyUp="TotalCostPerCd(<%=RsCdPrice("CdTitleId")%>);" onBlur="return Validate(<%=RsCdPrice("CdTitleId")%>);"
maxlength="25" tabindex="1">
</td>
<td align="center">
<%=RsCdPrice("CdCurrency")%>
<input type="text" name="lilaUnitCost<%=RsCdPrice("CdTitleId")%>" size="10" value="<%=RsCdPrice("CdPrice1")%>" readonly maxlength="25" tabindex="1" >
</td>
<td align="center">
<%=RsCdPrice("CdCurrency")%></font>
<input type="text" name="lilaAmount<%=RsCdPrice("CdTitleId")%>" size="10" value="<%=RsCdPrice("CdPrice1")%>" onChange="CalculateTotalAmount();" readonly maxlength="25" >
</td>
</tr>
<%
RsCdPrice.MoveNext
Wend
%>

<tr>
<td width="186">
<b>Total Amount</b></font>
</td>
<td align="center"><font class="hometextColor">
<%=cur%>
<input type="text" name="TotalAmount" readonly size="10" value="<%=amt%>" readonly maxlength="25" >
</td>

Also How can pass these values to the next page.

Please help
ShaRa

shanuragu
06-20-2003, 07:50 AM
Hi

With my code I was able to calculate amount immidiealy when quantity is entered. After using ur code it is not happening. Also where can I call the TotalCost function. I want to call that function when there is any change in the lilaAmount field(ie, onchange()). Please help

ShaRa

shanuragu
06-20-2003, 09:40 AM
Hi Dave
Thanks Dave.
My problem is solved now, ur code for TotalCost is working fine. By the way what are those elements(I am not vary good in js)??? I replaced them with getElementBy Id then it worked.
Can u please tell me How can I get these values (quantity & amount) in the next page.

ShaRa:D :(

shanuragu
06-20-2003, 10:31 PM
Hi

Sorry.. When I used ur code with elements, I was getting an error saying "elements is not an object", hence I had to change it to GetElementsById. Now I will change it back to elements & test.
Can u please tell me How can I pass these values to the next page.

I always need ur help.
Sorry again.

ShaRa:p