Create Dynamic Input Names or Input Fields in Asp

G

gotcha

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top