www.webdeveloper.com
Results 1 to 8 of 8

Thread: Dynamic Value in a List/Menu Form Field

  1. #1
    Join Date
    Dec 2002
    Posts
    177

    Dynamic Value in a List/Menu Form Field

    I need to display an HTML Form which includes a List/Menu field. The values in the List/Menu field are number (1,2,3,etc...).

    I have a recordset which has a dynamic value. If the dynamic value is set to 5, I want to display options 1,2,3,4,5. If the dynamic value is set to 2, then only show 1,2.

    So basically, the option list should no be greater than the dynamic value.

    HTML Code:
    <select name="quantity" id="quantity">
       <option value="1">1</option>
       <option value="2">2</option>
       <option value="3">3</option>
    </select>
    Brachole
    Web Development
    fcoloccia(at)prostatcorp.com

  2. #2
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    If myVal > 0 then response.write("<option value=""1"">1</option>")
    If myVal > 1 then response.write("<option value=""2"">2</option>")
    etc..

    unless you plan to have a lot, then you would use a loop like for i = 0 to myVal

  3. #3
    Join Date
    Dec 2002
    Posts
    177
    I don't think this is what I'm looking for. In your example, if myVal = 5, then the options would up to 5 numbers.

    HTML Code:
    <select name="quantity" id="quantity">
       <option value="1">1</option>
       <option value="2">2</option>
       <option value="3">3</option>
       <option value="4">4</option>
       <option value="5">5</option>
    </select>
    If myVal = 10, then it shows up to 10 numbers.

    HTML Code:
    <select name="quantity" id="quantity">
       <option value="1">1</option>
       <option value="2">2</option>
       <option value="3">3</option>
       <option value="4">4</option>
       <option value="5">5</option>
       <option value="6">6</option>
       <option value="7">7</option>
       <option value="8">8</option>
       <option value="9">9</option>
       <option value="10">10</option>
    </select>
    If myVal = 1, then it only shows 1 as a number.

    HTML Code:
    <select name="quantity" id="quantity">
       <option value="1">1</option>
    </select>
    Brachole
    Web Development
    fcoloccia(at)prostatcorp.com

  4. #4
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    That's what you asked for. I re-read your post and don't see a different meaning. Maybe you need to explain better what you want. I showed you how to get five options if your value is 5.

  5. #5
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    A simpler way, using a loop

    for i = 1 to myVal
    response.write("<option value="""&i&""">"&i&"</option>")
    next

  6. #6
    Join Date
    Dec 2002
    Posts
    177
    sorry about this...but I don't understand the '&i&'


    HTML Code:
    <select name="quantity" id="quantity">
            for i = <%=(rsOrderHistoryDetails.Fields.Item("DetailQuantity").Value)%>
    response.write("<option value="""&i&""">"&i&"</option>")
    next
    </select>
    Brachole
    Web Development
    fcoloccia(at)prostatcorp.com

  7. #7
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    This is ASP.. enclose your code properly:

    Code:
    <select name="quantity" id="quantity">
    <&#37;
            for i = 1 to rsOrderHistoryDetails.Fields.Item("DetailQuantity").Value)
    response.write("<option value="""&i&""">"&i&"</option>")
    next
    %>
    </select>
    Last edited by yamaharuss; 08-05-2009 at 04:55 PM.

  8. #8
    Join Date
    Dec 2002
    Posts
    177
    works like a charm...thanks a bunch!
    Brachole
    Web Development
    fcoloccia(at)prostatcorp.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles