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!

valuelist issue 2

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
I am using valuelist to put all values in a query into a list, but for some reason I the list returns:

one ,two ,three ,four ,five ,etc...

Why is there a space then a comma? The space shouldn't be there...


____________________________________
Just Imagine.
 
listfindnocase() is what you want, but the syntax is switched from findnocase().

try this:
Code:
<cfloop list="#FAList#" index="i" delimiters="|,">
 [color=red]<cfif listfindnocase(badwordslist,i)>[/color]
  <!--- if badwords found, increment by one --->
  <cfset badWordsstatus = badWordsstatus + 1>
 </cfif>            
</cfloop>

Joe
 
never mind the [color] part of that - my TGML was bad. try this:

Code:
<cfloop list="#FAList#" index="i" delimiters="|,">
 [COLOR=red]<cfif listfindnocase(badwordslist,i)>[/color]
  <!--- if badwords found, increment by one --->
  <cfset badWordsstatus = badWordsstatus + 1>
 </cfif>            
</cfloop>
 
Eureka!! It works now. This is the entire code for the badwords script.

Code:
<!--- gets all the badwords from the badwords table --->
  <cfquery name="badwordscheck" datasource="#default_ds#">
    SELECT RTRIM(BadWords) as BD
    FROM BadWordsTable
  </cfquery>

<!--- creates a list of the 'badwords' --->
	<cfset badwordslist = valuelist(badwordscheck.BD)>
<!--- sets badwordsstatus to 0 intially --->
	<cfset badWordsstatus = 0>
<!--- creates var to store badwords --->
	<cfset listMatches = "">
	
    <cfoutput>
	  <cfloop index="FAListIndex" from="#listfirst(fields)#" to="#listlast(fields)#">
		<cfset FAList = listappend(FAList,trim(getAnswers.FormAnswer))>
		<cfset FAList = Replace(FAList," ",",","ALL")>
		  <cfloop list="#FAList#" index="i" delimiters="|,">
    		<cfif listFindNoCase(badwordslist, i)>
      	<cfset listMatches = listAppend(listMatches,i)>
				<cfset badWordsstatus = badWordsstatus + 1>
    		</cfif>			
		  </cfloop>
		<cfset FAList = "">
	  </cfloop>	
	</cfoutput>


____________________________________
Just Imagine.
 
Sorry, hit "SUBMIT" too fast.

I wanna thanks everyone for helping me out on this. This is the entire bad words script:

Code:
<!--- gets all the badwords from the badwords table --->
  <cfquery name="badwordscheck" datasource="#default_ds#">
    SELECT RTRIM(BadWords) as BD
    FROM BadWordsTable
  </cfquery>

<!--- creates a list of the 'badwords' --->
	<cfset badwordslist = valuelist(badwordscheck.BD)>
<!--- sets badwordsstatus to 0 intially --->
	<cfset badWordsstatus = 0>
<!--- creates var to store badwords --->
	<cfset listMatches = "">
	
    <cfoutput>
	  <cfloop index="FAListIndex" from="#listfirst(fields)#" to="#listlast(fields)#">
		<cfset FAList = listappend(FAList,trim(getAnswers.FormAnswer))>
		<cfset FAList = Replace(FAList," ",",","ALL")>
		  <cfloop list="#FAList#" index="i" delimiters="|,">
    		<cfif listFindNoCase(badwordslist, i)>
      		  <cfset listMatches = listAppend(listMatches,i)>
		    <cfset badWordsstatus = badWordsstatus + 1>
    		</cfif>			
		  </cfloop>
		<cfset FAList = "">
	  </cfloop>	
	</cfoutput>


____________________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top