home *** CD-ROM | disk | FTP | other *** search
- <!--- This example uses ListFind and ListFindNoCase to see if a
- substring exists in a list --->
- <HTML>
- <HEAD>
- <TITLE>ListFindNoCase Example</TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
- <H3>ListFindNoCase Example</H3>
- <P>This example uses ListFind or ListFindNoCase to see if an exact string exists
- in a list
-
- <FORM ACTION="listfindnocase.cfm" METHOD="POST">
- <P>Try changing the case in Leary's last name:
- <BR><INPUT TYPE="Text" size=25 NAME="myString" VALUE="Leary">
- <P>Pick a search type:
- <SELECT NAME="type">
- <OPTION VALUE="ListFind" SELECTED>Case-Sensitive
- <OPTION VALUE="ListFindNoCase">Case-Insensitive
- </SELECT>
- <INPUT TYPE="Submit" NAME="" VALUE="Search Employee List">
- </FORM>
- <!--- wait to have a string for searching defined --->
- <CFIF IsDefined("form.myString") and IsDefined("form.type")>
-
- <CFQUERY Name="SearchEmpLastName" DATASOURCE="cfsnippets">
- SELECT FirstName, RTrim(LastName) AS LName, Phone, Department
- FROM Employees
- </CFQUERY>
-
- <CFSET myList = ValueList(SearchEmpLastName.LName)>
- <!--- Is this case-sensitive or case-insensitive searching --->
- <CFIF form.type is "ListFind">
- <CFSET temp = ListFind(myList, form.myString)>
- <CFIF temp is 0>
- <H3>An employee with that exact last name was not found</H3>
- <CFELSE>
- <CFOUTPUT>
- <P>Employee #ListGetAt(ValueList(SearchEmpLastName.FirstName), temp)#
- #ListGetAt(ValueList(SearchEmpLastName.LName), temp)#, of the #ListGetAt(ValueList(SearchEmpLastName.Department), temp)# Department,
- can be reached at #ListGetAt(ValueList(SearchEmpLastName.Phone), temp)#.
- <P>This was the first employee found under this case-sensitive last name search.
- </CFOUTPUT>
- </CFIF>
- <CFELSE>
- <CFSET temp = ListFindNoCase(myList, form.myString)>
- <CFIF temp is 0>
- <H3>An employee with that exact last name was not found</H3>
- <CFELSE>
- <CFOUTPUT>
- <P>Employee #ListGetAt(ValueList(SearchEmpLastName.FirstName), temp)#
- #ListGetAt(ValueList(SearchEmpLastName.LName), temp)#, of the #ListGetAt(ValueList(SearchEmpLastName.Department), temp)# Department,
- can be reached at #ListGetAt(ValueList(SearchEmpLastName.Phone), temp)#.
- <P>This was the first employee found under this case-insensitive last name search.
- </CFOUTPUT>
- </CFIF>
- </CFIF>
- </CFIF>
-
- </BODY>
- </HTML>
-
-