Using Related or Dependent Select With Lucee

Hello Community,

I just shifted from ColdFusion 9 to Lucee I’am in the process of shifting all my apps. During this shifting I am facing some issues so a request to the community to help me out.

Recently I am facing the Related Select or Dependent Select problem. The CFSELECT in Lucee does not support BIND attribute. Any Idea how to overcome this problem.


<cffunction name="GetRoles" access="remote" returnType="any">
	<cfquery name="lstRoles" datasource="#request.dsn#">
              SELECT  '' AS role_id, '--- ALL ---' AS role_name
             UNION ALL
             SELECT role_id, role_name 
             FROM   SUS_INDX_ROLE
             ORDER BY role_id ASC
	<cfreturn lstRoles>

<cffunction name="getSubRoles" access="remote" returnType="any">
<cfargument name="SUS_INDX_ROLE" type="any" required="true">
		<cfquery name="LstSubRoles" datasource="#request.dsn#">
			SELECT Sub_Role_Id, Role_id, Sub_Role_Name
			ORDER BY Role_id
	<cfreturn LstSubRoles>

My Form

Select Role (Optional):

       <div class="control-group">
    	<label class="control-label" for="title_id">Select Sub Role:</label>
	<div class="controls">
    	<cfselect name="SelSubRole" bind="cfc:Places.getSubRoles({SelRole})"
	display="Sub_Role_name" value="Sub_role_Id" bindOnLeoad="true"/>


Hi @fusioner, welcome!

There are certain tags in cfml that the own CF community discourages. The cause: they generate HTML and JavaScript that isn’t very flexible. In the link above you can see from older articles how to switch to real HTML selects. We really encourage you to do so.

Also, two weeks ago I’ve helped a user on Stack-Overflow creating an AJAX request with jQuery and CFML. Maybe that example can help as a start. There is also another user (@sos) who added an example of retreiving data from a cfc component with pure data. It’s worth to take a look at.



That being said, if you are not strong with ajax then look at the HTML5 datalist attribute.

What I did with a lot of code like this was just query everything before the page renders, then push everything into the datalist.

The second option would be flex-datalist.

1 Like

Also, make always sure to use cfqueryparam to prevent SQL injection.