ListValueCountNoCase

Description

Returns the number of instances of a value in a list. The search is not case-sensitive.

Category

List functions

Syntax

ListValueCountNoCase(list, value [, delimiters ]) 

See also

ListValueCount

Parameters

Parameter
Description
list
A list or the name of a list to search.
value
The string or number that the function is to find and count.
delimiter
Optional. The character(s) used to delimit elements in the list. The default is a comma.

Example

<!--- This example uses ListValueCountNoCase to find the 
number of employees in a department --->
<html>
<head>
<title>ListValueCountNoCase Example</title>
</head>

<body bgcolor = "#FFFFD5">

<cfquery name = "SearchByDepartment" datasource = "cfsnippets">
SELECT   Department
FROM   Employees
</cfquery>

<H3>ListValueCountNoCase Example</H3>
<P>This example uses ListValueCountNoCase to see how many
employees are in a department.

<form action = "listvaluecountnocase.cfm" method = "POST">
<P>Select a department:</P>
  <select name = "departmentName">
      <option value = "Accounting">
        Accounting
      </OPTION>  
      <option value = "Administration">
        Administration
      </OPTION>  
      <option value = "Engineering">
        Engineering
      </OPTION>  
      <option value = "Sales">
        Sales
      </OPTION>              
  </select>
  </select>
<input type = "Submit" name = "Submit" value = "Search Employee List">
</FORM>
<!--- wait to have a string for searching defined --->
<cfif IsDefined("FORM.Submit") and IsDefined("FORM.departmentName")>
  <cfset myList = ValueList(SearchByDepartment.Department)>
  <cfset numberInDepartment = ListValueCountNoCase(myList,
    FORM.departmentName)> 
     
  <cfif numberInDepartment is 0>
    <H3>There are no employees in <cfoutput>#FORM.departmentName#
    </cfoutput></H3>
  <cfelseIf numberInDepartment is 1>
    <cfoutput>
    <P>There is only one person in #FORM.departmentName#.
    </cfoutput>
  <cfelse>
    <cfoutput>
    <P>There are #numberInDepartment# people in #FORM.departmentName#.
    </cfoutput>
  </cfif>
</cfif>

</body>
</html>