Using multiple cfselects that are tied together
I recently needed a form that simulates a drill down function but I wanted to keep using plain Coldfusion functionality. Through the use of AJAX and CFSELECT's BIND function this was a breeze.
Part of the form now looks like this (buttons and stuff has been removed for readability):
<cfselect name="Vertical_Select" bind="cfc:com.ranking.getVerticalsArray()" bindOnLoad="true" required="yes" message="Product group is not defined"/>
<cfselect name="Software_Select" bind="cfc:com.ranking.getSoftwareArray({Vertical_Select})" required="yes" message="Product is not defined"/>
<cfselect name="Type_Select" bind="cfc:com.ranking.getTypesArray({Software_Select})" required="yes" message="Type is not defined"/>
</cfform>
Basically I'm telling my cfselect to use the array found in component ranking, method getVerticalsArray as it's value/text filling.
My array is built up like this (for all three cases):
<cfset verticals = getVerticals()>
<cfset verticalsArray = ArrayNew(2)>
<cfset verticalsArray[1][1]="">
<cfset verticalsArray[1][2]="-- choose a group --">
<cfloop from="1" index="i" to="#verticals.recordcount#">
<cfset verticalsArray[i+1][1]=verticals.autoID[i]>
<cfset verticalsArray[i+1][2]=verticals.Title[i]>
</cfloop>
<cfreturn verticalsArray>
</cffunction>
Important is using the "remote" access on the function (you'll find out soon enough if you forget to put this in).
The second CFSELECT uses a similar function, but then it uses the value from the first CFSELECT as an argument:
<cfargument name="VerticalID" type="string" hint="verticalID is a required numeric argument">
...etc...


There are no comments for this entry.
[Add Comment]