home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / listcontains.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.0 KB  |  64 lines

  1. <!--- This example shows ListContains --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ListContains Example</TITLE>
  5. </HEAD>
  6.  
  7. <BODY bgcolor=silver>
  8. <H3>ListContains Example</H3>
  9.  
  10. <CFIF IsDefined("form.letter")>
  11.     <!--- First, query to get some values for our list --->
  12.     <CFQUERY NAME="GetParkInfo" DATASOURCE="cfsnippets">
  13.     SELECT     PARKNAME,CITY,STATE
  14.     FROM    Parks
  15.     WHERE    PARKNAME LIKE '#form.letter#%'
  16.     </CFQUERY>
  17.     <CFSET tempList = #ValueList(GetParkInfo.City)#>
  18.     <CFIF ListContains("#tempList#", "#form.yourCity#") is not 0 OR form.yourCity is "">
  19.     <P><CFIF form.yourCity is "">The list of parks for the letter <CFOUTPUT>#form.Letter#</CFOUTPUT>
  20.         <CFELSE>There are parks in your city!
  21.        </CFIF>
  22.      <CFQUERY NAME="GetLocalParks" DATASOURCE="cfsnippets">
  23.         SELECT PARKNAME, CITY, STATE
  24.         FROM Parks
  25.         WHERE <CFIF form.yourCity is "">PARKNAME LIKE '#form.letter#%' <CFELSE>PARKNAME LIKE '#form.letter#%' AND city LIKE '#form.yourCity#%'</CFIF>
  26.         </CFQUERY>
  27.         <UL>
  28.         <CFOUTPUT query="GetLocalParks">
  29.             <LI><B>#Parkname#, <I>#City#, #State#</I></B>
  30.         </CFOUTPUT>
  31.         </UL>
  32.     <CFELSE>
  33.     <P>Sorry, there were no parks found for your city.
  34.     Try searching under a different letter.
  35.     </CFIF>
  36. </CFIF>
  37.  
  38. <P>Select a letter of the alphabet, and see
  39. if a park for your city is in the list of
  40. parks in the database for that letter.  This is a case-
  41. sensitive search.
  42. <P><I>If you are unsure if your city is represented,
  43. leave the city field blank and see the list of parks for
  44. each letter; or, enter only the first letter or two of
  45. that city.</I>
  46.  
  47. <FORM ACTION="listcontains.cfm" METHOD="POST">
  48. Letter Park Name begins with:
  49. <SELECT name="Letter">
  50.     <OPTION value="A" SELECTED>A
  51.     <CFSET temp = "B">
  52.     <CFLOOP FROM="1" TO="25" INDEX="Counter">
  53.     <OPTION value="<CFOUTPUT>#temp#">#Temp#</CFOUTPUT>
  54.     <CFSET temp = CHR("#Evaluate("#Asc("#temp#")# + 1")#")>
  55.     </CFLOOP>
  56. </SELECT>
  57. <P>Name of your city: <INPUT TYPE="Text" NAME="YourCity" VALUE="QUINCY">
  58. <BR>(<I>hint: try "A", "QUINCY"</I>)
  59. <INPUT TYPE="Submit" NAME="Find the Park">
  60. </FORM>
  61.  
  62. </BODY>
  63. </HTML>       
  64.