By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Create Dynamic Input Names or Input Fields in Asp

P: n/a
I have a little code to add multiple items to a shopping cart based
page. This code works perfect, but it adds all of the info to the
same input fields every time it loops. I need it to change the input
names each time it loops. Here is the code.
<% FOR x = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, x ) <> "" THEN
orderTotal = orderTotal + ( localCart( CARTPPRICE, x ) * localCart
( CARTPQUANTITY, x ) )

DIM chId,chProduct,chPrice,chQuantity
chId=(localCart( CARTPID, x) )
chProduct=Server.HTMLEncode( localCart( CARTPNAME, x ) )
chPrice=formatCurrency( localCart( CARTPPRICE, x ) )
chQuantity=localCart( CARTPQUANTITY, x )%>

<input name="Partnumber1" type="text" value="<%="" & chId & vbcrlf &
"" %>" size="40">
<input name="Partnumber2" type="text" value="<%="" & chProduct & ""
%>" size="40">
<input name="Partnumber3" type="text" value="<%="" & chPrice & "" %>"
size="40">
<input name="Partnumber4" type="text" value="<%="" & chQuantity & ""
%>" size="40">

<%
END IF
Next
%>

This is what I am getting with two items in the cart. Duplicate
PARTNUMBERS.

<input name="Partnumber1" type="text" value="07908-00036 " size="40">
<input name="Partnumber2" type="text" value="Right Mounting Bracket -
for Mounting Tape Drive to Chassis" size="40">
<input name="Partnumber3" type="text" value="$11.00" size="40">
<input name="Partnumber4" type="text" value="3" size="40">
<input name="Partnumber1" type="text" value="27303-69001 " size="40">
<input name="Partnumber2" type="text" value="ThinLAN (10Base-2) Board
- for NOVELL NetWare" size="40">
<input name="Partnumber3" type="text" value="$216.00" size="40">
<input name="Partnumber4" type="text" value="3" size="40">
I need to get different PARTNUMBERS such as this.

<input name="Partnumber1" type="text" value="07908-00036 " size="40">
<input name="Partnumber2" type="text" value="Right Mounting Bracket -
for Mounting Tape Drive to Chassis" size="40">
<input name="Partnumber3" type="text" value="$11.00" size="40">
<input name="Partnumber4" type="text" value="3" size="40">
<input name="Partnumber5" type="text" value="27303-69001 " size="40">
<input name="Partnumber5" type="text" value="ThinLAN (10Base-2) Board
- for NOVELL NetWare" size="40">
<input name="Partnumber7" type="text" value="$216.00" size="40">
<input name="Partnumber8" type="text" value="3" size="40">

Thanks for any help in advance.
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.