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
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