SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    epsom
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form Creation using loop

    Hi

    Can u help?

    I am trying to build a dynamic form based on user input.

    Here is the story i want a user to select how many times he/she wants to add a product and then depending on the number selected draw x number of input boxes for product name,price etc.

    Then pass this to another page, store in an array and add all this to a database!

    How can this be done..

    Thanks Nick

    PS - thanks recently for all your help at sitepoint.

  2. #2
    SitePoint Zealot Imran-Saami's Avatar
    Join Date
    Sep 2004
    Location
    Pakistan-Dubai
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Say your customer selected 5 products to enter

    noOfProducts = 5

    <form action="actions.asp">

    <% for i = 1 to noOfProducts %>

    <input type=text NAME="name"<% =i %> >
    <input type=text NAME="price"<% =i %> >
    :
    :
    'until all form items
    <input type=hidden Name="TotalForms" value=<% =noOfProducts %>>
    <% next %>
    </form>

    This file will be recieving all submitted values and extract and add to DB, supposing here that u've opened a recordset with Batch Update enable.

    Actions.asp

    noOfProducts = request("noOfProducts")
    for i = 1 to noOfProducts

    RS.AddNew
    RS("Name") = Request("name" & i )
    RS("Price") = Request("price" & i )
    :
    :
    'all form items

    next
    RS.Update

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    epsom
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks v much imran


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •