I Need a procedure to dinamically populate 3 drop-down menus depending on the selection of the first drop-down menu

I have 3 drop-down menus in a form
Question1  has 3 options. Depending on the answer to question1, question2 will  show 6 to 10 options. Depending on the answer to the question 2,  the third one will show options that will be populated from a db table. Question 3 options MUST come from a table

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

danrosenthalConnect With a Mentor Commented:
This code (thanks to TallerMike) should get you on the right track...

<script src="http://mike.kingery.com/inc/js/filterSelect.js"></script>
<script language="JavaScript">
auto_enable_disable = true;

<form name="carForm">

<select name="company" onchange="filterSelect(model,this)">
<option value=""></option>
<option value="ford">Ford</option>
<option value="chevy">Chevy</option>
<option value="audi">Audi</option>

<select name="model" onchange="filterSelect(edition,this)" disabled="true">
<option value="" filter=""></option>
<option value="pickup" filter="ford">Ford Pickup</option>
<option value="van" filter="ford">Vans</option>
<option value="caprice" filter="chevy">Caprice</option>
<option value="corvette" filter="chevy">Corvette</option>
<option value="A4" filter="audi">A4</option>
<option value="A6" filter="audi">A6</option>

<select name="edition" disabled="true">
<option value="" filter=""></option>
<option value="F150" filter="pickup">F150</option>
<option value="F250" filter="pickup">F250</option>
<option value="F350" filter="pickup">F350</option>
<option value="CClassic" filter="caprice">Caprice Classic</option>
<option value="COnv" filter="corvette">Corvette Convertible</option>
<option value="CZ6" filter="corvette">Corvette Z6</option>
<option value="Wagon" filter="caprice">Caprice Wagon</option>
<option value="Cvan" filter="van">Cargo Van</option>
<option value="A627" filter="A6">A6 2.7L</option>
<option value="A643" filter="A6">A6 4.3L</option>
<option value="A427" filter="A4">A4 2.7L</option>
<option value="A430" filter="A4">A4 3.0L</option>
gaby22Author Commented:
It does what I want but as i said the last option needs to be populated from a query like
<cfquery datasource="db" name=opts">
select * from table where field_name = '#question2_value#'

<cfouput query= opts>
<option value="#opts.fieldname#">#opt.fieldname#</option>

I don't know how to get the question2_value to run the query
Dan has set it up correctly.  There's no way to populate the third select field without doing a page post.  What you'll need to do is select ALL records in your query.

<cfquery datasource="db" name="opts">
SELECT id, value, field_name
  FROM table

<select name="edition" disabled="true">
  <cfoutput query="db">
    <option value="#opts.id#" filter="#opts.field_name#">#opts.value#</option>

opts.fieldname is equal to your value for the second dropdown.
and your table should have the basic structure of
id   value   field_name
1    F150   pickup
2    F250   pickup
3    A627   A6
4    A643   A6
mrichmonConnect With a Mentor Commented:
Try the 3 related selects tag available fro free from macromedia cold fusion exchange :


Enter "Related Selects" and choose cold fusion from the drop down menu.

It shows how to make each dependent on eahc other and how to populate from a query

All Courses

From novice to tech pro — start learning today.