Forums
This topic is locked
Grabbing Values from dynamic form.
Posted 26 Mar 2006 22:53:25
1
has voted
26 Mar 2006 22:53:25 Dawie Harmse posted:
Hi Guys, I hope someone can help me out with this. My problem is the following:I create my textfields in my form like this:
<%
counter=0
do until rs.eof
counter=counter+1
%>
<%=counter%>. <%=rs("Title"%>
Qty
<input name="cost<%=counter%>" type="hidden" value="<%=rs("Price"%>">
<input name="qty<%=counter%>" class="orangeform" value="0" size="3">
<%
rs.movenext
loop
%>
But my problem is, how can I grab the values of each of the input fields?
If I do it like This:
<%
for i=1 to counter
cost""&i&"" = request.form("cost"&i&""
qty""&i&"" = request.form("qty"&i&""
Subtotal""&i&"" = ("cost "&i&"" * "qty"&i&""
next
%>
I receive and error: Type mismatch: 'cost'
Edited by - dawieharmse on 26 Mar 2006 22:55:59
Replies
Replied 27 Mar 2006 00:45:52
27 Mar 2006 00:45:52 micah santos replied:
This is a common error that happens when you're trying to stuff two different types of variable.
ictr = 100
then it fail at some point, when it turns out to be like this
ictr = "abc"
Hope this helps:
<%
for i=1 to counter
cost""&i&"" = cInt(request.form("cost"&i&"")
qty""&i&"" = cInt(request.form("qty"&i&"")
Subtotal""&i&"" = ("cost "&i&"" * "qty"&i&""
next
%>
ictr = 100
then it fail at some point, when it turns out to be like this
ictr = "abc"
Hope this helps:
<%
for i=1 to counter
cost""&i&"" = cInt(request.form("cost"&i&"")
qty""&i&"" = cInt(request.form("qty"&i&"")
Subtotal""&i&"" = ("cost "&i&"" * "qty"&i&""
next
%>
Replied 02 Apr 2006 10:36:15
02 Apr 2006 10:36:15 micah santos replied:
<%
intRecIDs = Replace(counter, "*", ""
arrRecIDs = Split(intRecIDs, ", "
For i = 0 to Ubound(arrRecIDs)
intCost = Replace(Request.Form("cost" & arrRecIDs(i)), "'", "''"
intQty = Replace(Request.Form("qty" & arrRecIDs(i)), "'", "''"
SbTotal = intCost - intQty
Next
%>
intRecIDs = Replace(counter, "*", ""
arrRecIDs = Split(intRecIDs, ", "
For i = 0 to Ubound(arrRecIDs)
intCost = Replace(Request.Form("cost" & arrRecIDs(i)), "'", "''"
intQty = Replace(Request.Form("qty" & arrRecIDs(i)), "'", "''"
SbTotal = intCost - intQty
Next
%>