Skip to main content
December 28, 2012
Question

second dropdown based on previous dropdown?

  • December 28, 2012
  • 2 replies
  • 725 views

Greetings

There seems to be no easy way to accomplish this without javascript/CF  with dozens of lines of code.

The scenario: table 1 has banks, table 2 has loan processors. Client chooses bank from DDSB, only the processors from that choice show up in the second.

Processor table has FK relationship to bank PK.

ColdFusion 9.0.1,
Microsoft SQL Server 2008 R2

Is there a simpler solution?

Thanks and have a great New Year.

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
December 28, 2012

You can do this by means of the bind attribute of cfselect, easy peasy. In fact, the ColdFusion documentation on cfselect has a fully worked out example.

Have a look at the CFM and CFC of the last example. All you have to do is replace States with Banks, and Cities with LoanProcessors. The functions then become getBank() and getLoanProcessors().  Each runs a query. The first function returns an array of banks, the second an array of loan processors for a given choice of bank.

Inspiring
December 28, 2012

Bind your dropdowns to cfc methods.  The documentation on cfinput has examples.