Is there a way in Zend Framework to fill a combobox with values depending on the value chosen in a previous combobox, but on the same page?
In my case I have a combobox for domain and one for specialization. If i choose Informatics in the first combobox (domain), I want to fill the second one with a single specialization - "Informatics". But if I choose Math in the first, I want to fill the second one with two specialization: "Mathematics" and "Mathematics & Informatics".
Thank you! Sorin
I've used a very simple solution: I've put the option to choose the domain on one page and the option to choose the specialization on another page, based on the domain chosen.
if you have the data with relationships between domain and specialisation in a database in your server. you can attach a listener on change event to your domain combo box and fill the second combo box accordingly by retrieving specialisations of the selected domain using an ajax post request :
here's an example using jquery :
$(".domain").change(function()
{
var domainId=$(this).val();
var dataString = 'domainId='+ domainId;
$.ajax
({
type: "POST",
url: baseurl+"getSpecialisations",
data: dataString,
cache: false,
success: function(html)
{
$(".specialisation").html(html);
}
});
});
and in your controller create an action getSpecialisationsAction that will retrieve your domain's specifications, check here for an example of how to send post request to a zend action .