listValueCountNoCase

Description

Counts instances of a specified value in a list. The search is case-insensitive.

Categories

Related

Syntax

ListValueCountNoCase(list, value [, delimiters ])

Attributes

AttributeDescriptionRequiredDefault
delimitersA string or a variable that contains one. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter.
listA list or a variable that contains one.
valueString or number, or a variable that contains one. Item for which to search. The search is case-insensitive.

Returns

The number of instances of value in the list.

Example

<cfquery name = "SearchByDepartment" datasource = "cfdocexamples"> 
SELECT     Department 
FROM     Employees 
</cfquery> 
 
<h3>ListValueCountNoCase Example</h3> 
This example uses ListValueCountNoCase to count employees in a department. 
 
<form action = "listvaluecountnocase.cfm"> 
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>        There is only one person in #FORM.departmentName#. 
        </cfoutput> 
    <cfelse> 
        <cfoutput>        There are #numberInDepartment# people in #FORM.departmentName#. 
        </cfoutput> 
    </cfif> 
</cfif>