Multiple Section List

Results 1 to 2 of 2

Thread: Multiple Section List

  1. #1
    Bobby Guest

    Default Multiple Section List

    I have a form which contains a select field that can have multiple selections. For instance, I have a select field and the options are "California, Arkansas, Washington, Nevada" Now, the user can select one or more than one option. The option(s) he selects will be used as the querying variable in my SQL stmnt. "SELECT * FROM customers WHERE state = &#039"&Request("state")&"&#039. This works fine if he chooses just one option, but how do I configure this if he chooses more than one option???<BR><BR>PLEASE HELP!!<BR><BR>Thanks

  2. #2
    omc Guest

    Default RE: Multiple Section List

    I don&#039t know if this is the most efficient method, but I would loop through all the items in the drop down list, assign each selected item to an array and build the query statement item by item.<BR><BR>The following is something I did for a project. It is a little different because I had a form that had checkboxes. The form was created dynamically so I didn&#039t know how many checkboxes there would be on the page. So first I had to find out how many checkboxes there were and then loop through and assign each checked one to an element in an array. At the same time I built my query string.<BR><BR>&#039begin query statemnt<BR>qrySelect="SELECT pub_id, pub_number,title,date_statement FROM Tbl_Publications where pub_id=0"<BR>&#039pub_id=0 is a red herring by the way because I had to start the where statement without an "OR"<BR><BR>&#039find out how many items you need in the array. you just need the items that were checked.<BR>for i=1 to intCount<BR>strOrder="order" & i<BR>if Request.Form(strOrder)&#060;&#062;"" then<BR>intNumOrders=intNumOrders+1<BR>end if<BR>next<BR><BR>&#039declare array<BR>dim arrPubs()<BR>redim arrPubs(intNumOrders)<BR><BR>&#039assign form data to array and create part of query string<BR>for i=1 to intCount<BR>strOrder="order" & i<BR>if Request.Form(strOrder)&#060;&#062;"" then<BR>arrPubs(intNumOrders2)=Request.Form(strOrd er)<BR>qrySelect=qrySelect & " OR pub_id=" & arrPubs(intNumOrders2)<BR>intNumOrders2=intNumOrde rs2+1<BR>end if<BR>next<BR><BR>&#039finish query statment and execute it<BR>qrySelect=qrySelect & " ORDER BY pub_number"<BR>set List=Conn.Execute(qrySelect)

Posting Permissions

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