I have seen some answers relating to my question but these didn't help me getting my result. I am using zend framework 1.12 and I have to implement dependent drop downs form elements coming from two different tables.
My form Elements:
$country = new Zend_Form_Element_Select('Country');
$country -> setLabel('Country');
$city = new Zend_Form_Element_Select('city');
$city -> setLabel('City:');
$this->addElements(array($country,$city));
Country Table is parent Table of City Table and Using Zend_Dbtable and jQuery.
Would anyone please show me how to do this by using jQuery and AJAX. I mean from Controller to View.
When loading the form from controller you can set the countries drop-down value from Controller like:
And in ajax based on the select change(Country), make a ajax call to load cities:
Else:
you know the selected country during the form load, get the cities for selected country and assign like,
Else:
Assign to Countries List and Select cities list to view variables and use the view variable in view file and use the foreach statement to assign the option values to drop down for both Country and City(Select drop-down).
I hope this helps.