shanuragu
06-20-2003, 02:32 AM
Hi
I have dispalyed text boxes with same name using a while loop. But to differentiate them, each text box name is concatinated with the record Id(ie cdid here).
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 values in the amount field. & display that in the Total Amount Field.
Here is the js code for calculating amount .
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
%>
* This is a total amount field
<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 store these values in session variable Or How can I pass these values like Qty, amount & grandtotal amount in to the next page
Please help
ShaRa
I have dispalyed text boxes with same name using a while loop. But to differentiate them, each text box name is concatinated with the record Id(ie cdid here).
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 values in the amount field. & display that in the Total Amount Field.
Here is the js code for calculating amount .
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
%>
* This is a total amount field
<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 store these values in session variable Or How can I pass these values like Qty, amount & grandtotal amount in to the next page
Please help
ShaRa