Populate 2nd dropdown from 1st dropdown

Populate a second dropdown based on the first dropdown selection.

Overview

The issue occurs because the second dropdown's data is loaded during the form's initial load, not dynamically when the first dropdown changes.
Use the double dropdown method described in the ChronoForms FAQs to dynamically filter the second dropdown's options based on the value selected in the first dropdown.

Answered
Fa Fawaaz 16 Jul, 2015
Hello,

I'm using 2 DB READ to populate 2 simple dropdown from two different tables.
Dropdown1 gets its data from model M1(Table Tbl1)
Dropdown2 gets its data from model M2(Table Tbl2)
Both table contain the field COLOR.
The data is displayed on the form with no problem.So far so good

What I need to do :
When I select something in Dropdown1, Dropdown2 needs to get populated only with the corresponding values.
For example if i select RED in Dropdown1, Dropdown2 should show me records which have RED as COLOR.

Can someone guide on achieving this please?
I need this :
1. Get selected value in Dropdown1
2. Populate Dropdown2 with list of values WHERE field = selected value in Dropdown1

I have tried using a condition in Dropdown2, but its not working. I think its because it is in the ON LOAD block..I dunno..
<?php
return array('M2.COLORS' => $form->data['M1']['COLORS']);
?>


<?php
return array('M2.COLORS' => $form->data['Dropdown1']['']);
?>


I'm getting Notice: Undefined index: M1
Gr GreyHead 16 Jul, 2015
Answer
Hi Fawaaz,

Please check the FAQs for 'double drop-down'.

Bob
This topic is locked and no more replies can be posted.