Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database search based on multiple selections in a list box 1

Status
Not open for further replies.

lminmei

Programmer
Feb 1, 2000
111
US
how do i write the code to search on multiple selections from a list box???<br><br>ok...i have a list box on a cfm page:<br>&lt;form action=&quot;getwatch.cfm&quot; method=&quot;post&quot;&gt;<br>&lt;select name=&quot;watches&quot; size=&quot;3&quot; multiple&gt;<br>&nbsp;&nbsp;&lt;option value=&quot;&quot;&gt;Select Brand(s)<br>&nbsp;&nbsp;&lt;option value=&quot;Rolex&quot;&gt;Rolex<br>&nbsp;&nbsp;&lt;option value=&quot;Tag&quot;&gt;Tag<br>&nbsp;&nbsp;&lt;option value=&quot;Omega&quot;&gt;Omega<br>&nbsp;&nbsp;&lt;option value=&quot;Gucci&quot;&gt;Gucci<br>&lt;/select&gt;<br>&lt;/form&gt;<br><br>ok -&nbsp;&nbsp;now on my search results page i have.....<br>&lt;cfquery name=&quot;watches&quot; datasource=&quot;Watches&quot;&gt;<br>SELECT *<br>FROM watches<br>WHERE ID = ID<br><br>&lt;cfif IsDefined(&quot;form.watches&quot;) IS &quot;yes&quot;&gt;<br>&nbsp;&nbsp;&lt;cfif form.watches is not &quot;&quot;&gt;<br>&nbsp;&nbsp;AND watches LIKE '#Form.watches#'<br>&nbsp;&nbsp;&lt;/cfif&gt;<br>&lt;/cfif&gt;<br><br>ORDERED BY watches<br>&lt;/cfquery&gt;
 
Change:<br>&lt;cfif form.watches is not &quot;&quot;&gt;<br>&nbsp;&nbsp;AND watches LIKE '#Form.watches#'<br>&lt;/cfif&gt;<br><br>To:<br>&lt;cfif form.watches is not &quot;&quot;&gt;<br>&nbsp;&nbsp;AND (watches LIKE '#ListChangeDelims(form.watches, &quot;' OR watches LIKE '&quot;)#')<br>&lt;/cfif&gt;<br><br>Hope this helps...<br><br>DM
 
DarkMan,<br><br>thanks for the help but now i want to do the the same thing for &quot;Year&quot;.... however it keeps on giving me an error...<br><br>is this correct?<br><br>&lt;cfif form.year is not &quot;&quot;&gt;<br>&nbsp;&nbsp;AND (year LIKE #ListChangeDelims(form.year, &quot;'OR Year&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;LIKE'&quot;)#)<br>&lt;/cfif&gt;<br><br>please tell me what i'm doing wrong.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top