Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    128
    Thanks
    6
    Thanked 0 Times in 0 Posts

    How to request an unknown number of variables

    Hi all,

    I have a form and there are three drop down menus (adults, children, infants) which has the values from 0 to 10. My javascript code adds new text fields to the form when the drop down menu changes.
    For Example:
    Selected option is 0. When the client changes adults drop down to 2, children drop down to 1 and infants drop down to 1, I want the code add
    <input type="text" name="adult1" /><br>
    <input type="text" name="adult2" /><br>
    <input type="text" name="child1" /><br>
    <input type="text" name="inf1" /><br>
    to the HTML.

    So the number of variables are different. We get the number of adults, children, infants from the drop down menu values and text field names goes like adult1,2,3,4

    How can I get these values to separate variables? Can anyone send an example code?


    Thanks
    Ceyhun

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,071
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Using a For Each loop will get the values of all form elements.

    here is an example that will write them to the page.
    Code:
    For Each Item in Request.Form
          Response.Write Item & " = " & Request.Form(Item) & "<br>"
    Next


  •  

    Posting Permissions

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