home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Documentation / snippets / listcontains.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  2.1 KB  |  65 lines

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