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!

how to insert ","s (commas) into cfsearch criteria? 1

Status
Not open for further replies.

gtbikerider

Technical User
May 22, 2001
81
GB
I'm using verity to search. The user naturally enters an unknown number of words which are used as the criteria to search on. The words need to be separated by commas as I understand it [and there may well be a better way to achieve this?].

code is:
<cfsearch name="results" collection="collection" type="simple" criteria="#criteria#">

How do ensure that if the user enters...
"dogs fish cats"
I use "dogs, fish, cats," as the criteria?


--
John
 
you don't want "dog, fish, cat" either. you want "dog,fish,cat", no spaces.

anyway.

<cfset criteria = "dog, fish cat">
<!--- remove all ", " (comma then space) that will prevent "dog,,fish,cat" after it is all done --->
<cfset criteria = replace(criteria, ", ", ",","ALL")>
<!--- remove all " " (spaces with no comma's before it) --->
<cfset criteria = replace(criteria, " ", ",","ALL")>


Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top