Skip to main content
Inspiring
February 20, 2012
Question

Chaining select lists

  • February 20, 2012
  • 1 reply
  • 4281 views

Hi,

I try to create two dynamic  depending  selectlists whereas the second select list depends on the choose of the first list.

Both lists are populated by a database query.

Here is a simple example:

First list: Usergroups

<cfselect name="usergroups" >

<cflloop query="select_usergroup">

<option value="id">#usergroup_name#

</cfselect>

Second list: Users

<cfselect name="users" >

<cflloop query="select_user">

<option value="id">#user_name#

</cfselect>

When selecting a usergroup in  the first list, the query of the second list runs in dependence of the value of first list.

Is there a possibility to solve this problem without using Url-parameter? I have a big formular with many form-fields and I assume that this method is not very fast.

I also try to use data binding, but then I have a problem preselecting values in the lists.

Environment: Oracle 11g, ColdFusion 9 Standard

Any idea?

regards Claudia

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
February 20, 2012

Example 2 in the Livedocs on cfselect is a fully worked-out example. It consists of 3 files:  a CFC (BinFons.cfc) and an XML file(states.xml) and a CFM page containing the form and cfselect tags(call it, say, formPage.cfm). All you have to do is place the files in the same directory.

biene22Author
Inspiring
February 20, 2012

Yes, I know this example and it works very well.

But how to preselect values in the selectboxes when loading the page for the first time?

I get the values from a database query and have to set this values as selected in the selectboxes.

Documentation said that "selected" attribute applies only if selection list items are generated from a query.

BKBK
Community Expert
Community Expert
February 20, 2012

biene22 wrote:

Yes, I know this example and it works very well.

But how to preselect values in the selectboxes when loading the page for the first time?

I get the values from a database query and have to set this values as selected in the selectboxes.

Documentation said that "selected" attribute applies only if selection list items are generated from a query.

What is the problem then?