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

  1. <!--- This example uses ListFind and ListFindNoCase to see if a
  2. substring exists in a list --->
  3. <HTML>
  4. <HEAD>
  5. <TITLE>ListFindNoCase Example</TITLE>
  6. </HEAD>
  7.  
  8. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  9. <BODY  bgcolor="#FFFFD5">
  10. <H3>ListFindNoCase Example</H3>
  11. <P>This example uses ListFind or ListFindNoCase to see if an exact string exists
  12. in a list
  13.  
  14. <FORM ACTION="listfindnocase.cfm" METHOD="POST">
  15. <P>Try changing the case in Leary's last name:
  16. <BR><INPUT TYPE="Text" size=25 NAME="myString" VALUE="Leary">
  17. <P>Pick a search type:
  18.     <SELECT NAME="type">
  19.         <OPTION VALUE="ListFind" SELECTED>Case-Sensitive
  20.         <OPTION VALUE="ListFindNoCase">Case-Insensitive
  21.     </SELECT>
  22. <INPUT TYPE="Submit" NAME="" VALUE="Search Employee List">
  23. </FORM>
  24. <!--- wait to have a string for searching defined --->
  25. <CFIF IsDefined("form.myString") and IsDefined("form.type")>
  26.  
  27. <CFQUERY Name="SearchEmpLastName" DATASOURCE="cfsnippets">
  28. SELECT     FirstName, RTrim(LastName) AS LName, Phone, Department
  29. FROM     Employees
  30. </CFQUERY>
  31.  
  32. <CFSET myList = ValueList(SearchEmpLastName.LName)>
  33. <!--- Is this case-sensitive or case-insensitive searching --->
  34. <CFIF form.type is "ListFind">
  35.     <CFSET temp = ListFind(myList, form.myString)>
  36.     <CFIF temp is 0>
  37.         <H3>An employee with that exact last name was not found</H3>
  38.     <CFELSE>
  39.         <CFOUTPUT>
  40.         <P>Employee #ListGetAt(ValueList(SearchEmpLastName.FirstName), temp)#
  41.         #ListGetAt(ValueList(SearchEmpLastName.LName), temp)#, of the #ListGetAt(ValueList(SearchEmpLastName.Department), temp)# Department,
  42.         can be reached at #ListGetAt(ValueList(SearchEmpLastName.Phone), temp)#.
  43.         <P>This was the first employee found under this case-sensitive last name search.
  44.         </CFOUTPUT>
  45.     </CFIF>
  46. <CFELSE>
  47.     <CFSET temp = ListFindNoCase(myList, form.myString)>
  48.     <CFIF temp is 0>
  49.         <H3>An employee with that exact last name was not found</H3>
  50.     <CFELSE>
  51.         <CFOUTPUT>
  52.         <P>Employee #ListGetAt(ValueList(SearchEmpLastName.FirstName), temp)#
  53.         #ListGetAt(ValueList(SearchEmpLastName.LName), temp)#, of the #ListGetAt(ValueList(SearchEmpLastName.Department), temp)# Department,
  54.         can be reached at #ListGetAt(ValueList(SearchEmpLastName.Phone), temp)#.
  55.         <P>This was the first employee found under this case-insensitive last name search.
  56.         </CFOUTPUT>
  57.     </CFIF>
  58. </CFIF>
  59. </CFIF>
  60.  
  61. </BODY>
  62. </HTML>       
  63.     
  64.