Create Dynamic Input Names or Input Fields in Asp

Discussion in 'ASP General' started by gotcha, Oct 24, 2003.

  1. gotcha

    gotcha Guest

    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.
     
    gotcha, Oct 24, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paddy McCarthy
    Replies:
    3
    Views:
    719
    Anthony J Bybell
    Sep 24, 2004
  2. Bob
    Replies:
    1
    Views:
    387
    Lucas Tam
    Jul 30, 2004
  3. Lewis G. Pringle, Jr.
    Replies:
    0
    Views:
    602
    Lewis G. Pringle, Jr.
    Sep 30, 2003
  4. Sandman

    input names with '-' in their names.

    Sandman, Sep 3, 2003, in forum: Javascript
    Replies:
    4
    Views:
    105
    Lasse Reichstein Nielsen
    Sep 4, 2003
  5. Replies:
    23
    Views:
    521
    Tim Streater
    Dec 18, 2013
Loading...

Share This Page