Oops - that's what I get for writing code on the fly.  Try this instead:

<!--- mySearchParans is just an example of a possible search string --->
<CFSET mySearchParams = "Guitar Case and string">

<CFSET SearchArr = ListToArray(mySearchParams, " ")>
<CFSET SearchLen = ArrayLen(SearchArr)>
<CFSET SearchFormat = "null">
<CFOUTPUT>Len:#SearchLen#</CFOUTPUT>

<CFLOOP FROM="1" TO="#SearchLen#" INDEX="x">
   <CFIF SearchFormat EQ "null">
       <CFSET SearchFormat = "myColName = """ & "#SearchArr[x]#""">
   <CFELSE>
       <CFSET SearchFormat = "#SearchFormat#" & " OR myColName = """ & 
"#SearchArr[x]#""">
   </CFIF>
</CFLOOP>


<CFQUERY ...>
   SELECT blah1, blah2, blah3
   FROM myTable
   WHERE #SearchFormat#
</CFQUERY>


>From: "Jeanne Sarfaty Glazer" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: CF-Talk <[EMAIL PROTECTED]>
>Subject: Multiple Inputs (was Re: Textbox validation)
>Date: Fri, 23 Mar 2001 10:09:49 -0500
>
>Will,
>
>Have you considered treating the textbox string as a list, breaking it 
>apart
>for your query (in your example) "bass" OR "guitar" OR "other list item".
>This way you can allow your users to enter multiple words.  The part I'm 
>not
>sure about is how my example below affects performance (I'm still new to
>things like database tuning)
>
>e.g.
>
>mySearchParams = "Bass Guitar Music"
>
><CFSET SearchLen = ListLen(mySearchParams)>
><CFSET SearchArr = ListToArray(mySearchParams)>
><CFSET SeachFormat = "">
>
><CFLOOP FROM="1" TO="#SearchLen#" INDEX="x">
>    <CFIF SearchFormat EQ "">
>        <CFSET SearchFormat = "myColName = """ & "#SearchArr[x]#""">
>    <CFELSE>
>        <CFSET SearchFormat = " OR myColName = """ & "#SearchArr[x]#""">
>    </CFIF>
></CFLOOP>
>
>
><CFQUERY ...>
>SELECT blah1, blah2, blah3
>FROM myTable
>WHERE #SearchFormat#
></CFQUERY>
>
>
>
> >From: "W Luke" <[EMAIL PROTECTED]>
> >Reply-To: [EMAIL PROTECTED]
> >To: CF-Talk <[EMAIL PROTECTED]>
> >Subject: Re: Textbox validation
> >Date: Fri, 23 Mar 2001 13:30:28 -0000
> >
> >Thanks for all the replies.  The reason I need to prevent more than one
> >word
> >being entered, is I'm finding it impossible to use wildcard filtering 
>using
> >Access' Instr function (any clues anyone?) - for example, if the search
> >string contained "Bass Guitar" it would only return True if it *matches*
> >it,
> >and not if it's similar (Like).
> >
> >Anyways, thanks - going to do what Aidan suggests, and add the Javascript
> >when I have time.
> >
> >Will
> >--
> >[EMAIL PROTECTED] -=- www.lukrative.com
> >Local-Advertising -=- www.localbounty.com
> >
> > > Really the best way is *both*.
> > > JavaScript is much nicer from a user interface point of view.
> > > But if the validation is important you need to do it again on
> > > the server, because you can't guarantee the user has JavaScript
> > > running in their browser.
> > >
> > > Nick
> > >
> > > -----Original Message-----
> > > From: W Luke [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, March 23, 2001 12:39 AM
> > > To: CF-Talk
> > > Subject: Textbox validation
> > >
> > >
> > > Hi,
> > >
> > > On one textbox I need to prohibit users entering more than one word - 
>I
> > > don't want them to enter a space.  What's the best way of doing this -
> > > Javascript, or Cold Fusion after the form has been posted?
> > >
> > > Thanks.
> > >
> > > Will
> > > --
> > > [EMAIL PROTECTED] -=- www.lukrative.com
> > > Local-Advertising -=- www.localbounty.com
> > >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to