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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dealing With Multiple Select Tags

    I am trying to make an order form using asp/vbscript that will get the values of multiple HTML select menus at one button click, and then pass that all of the information to another asp page which will do the processing and deal with the database stuff. my problem is that i am unable to retrieve each value from the select menus, instead i only get 0 the default value. does anyone know how i can accomplish this? my original idea was to just put all values in an array and pass that to another page which will deal with each item.

    i have pasted my code bellow.
    THanks!

    Code:
    if not rs.bof or not rs.eof then
        do while not rs.eof
            thisformlet = ""
            
    dim thepic
    thepic =rs("picture")
    cstr(thepic)
    
    
    
    
    if cat = rs("type")then
    %>
    <form name="order1" method="post" action="default5.asp" >
     <tr align="center">
          <td width="25%" ><a class="thumbnail" href="#thumb"><%=rs("formnum")%><span><img src=<%response.Write(thepic)%> border="0" /></span></a></td>
          <td width="25%"><%=rs("Description")%></td>
          <td width="25%"><%=rs("Packs Of")%></td>
          <td width="25%" valign="middle">
            <select name="qty<%response.Write(count)%>">
              <option value="0">0</option>
              <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>
              </td>
        </tr>
    
            <%
            rs.movenext
    
    else  
    
    
        cat = rs("type")
        newcat = 1        
        if newcat = 1  then%> <!--a new catagory is discovered-->
        <tr><td align="left" bgcolor="#808080" colspan="4" height="30px"> &nbsp; <font color="ffffff" style="font-size:12pt"><b>
        <%
         response.Write(cat)  %></b></font></td> </tr> <%
         newcat = 0 
         end if
         %>
          <tr align="center">
          <td width="25%" ><a class="thumbnail" href="#thumb"><%=rs("formnum")%><span><img src=<%response.Write(thepic)%> border="0" /></span></a></td>
          <td width="25%"><%=rs("Description")%></td>
          <td width="25%"><%=rs("Packs Of")%></td>
          <td width="25%" valign="middle">
            <select name="qty<%response.Write(count)%>">
              <option value="0">0</option>
              <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>
              </td>
        </tr>
        <%
    
            rs.movenext 
    end if    
            
    count = count + 1 ' gives all qty boxes unique names        
        loop
        
    else
        response.Write("<tr align=""center""><td colspan=""8"">There are currently no forms available to order.</td></tr>")
    end if
    
    
    
    rs.close()
    set rs = nothing
    %>
      
     
    
    </td></tr>
    <!-- content ends here -->
    </td>
    </td>
    </tr></table>
    
    
    
    
    <br />
    
    
      <input type="button" name="order1" value="Order!" onClick="">
    </form>
       
    
     
     
    <%
    dim totalsize
    totalsize= count
    count = 0
    
    for count= 0 to totalsize
    qtyname = "qty" & count
    response.Write(qtyname)
    request.Form(qtyname)
    If qtyname<>"" Then
         response.Write("the item is be written")
         count
    End If
    count = count+ 1
    next
    Last edited by Brandoe85; 08-12-2008 at 01:22 PM. Reason: added code tags

  • #2
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Try to loop through all the form elements dynamically.
    You can use the following code for the same:

    for each obj in request.form
    fieldName = fieldName & "," & obj
    fieldvalue = fieldvalue & "," & request(obj)
    next
    Hope it helps..

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Two things.

    First, please put code into [ CODE ] brackets when you're posting. It makes it much easier for us to read.

    Second, it's not clear what the logic of this page is trying to accomplish but I'd have a good look at the HTML it's outputting. It looks to me like you're only writing the opening <form> tag if the condition of an if..else is met, and you're writing the closing </form> tag if that condition isn't met. So I'd check first of all that you're outputting a correctly formatted, valid HTML form.


  •  

    Tags for this Thread

    Posting Permissions

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