Zend - combobox value depending on another combobox value

Go To StackoverFlow.com

0

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

2012-04-05 18:12
by Sorin Adrian Carbunaru
Have you tried AJAX? when one of the combo boxes changes do an AJAX request to the server and return a json object containing the option for the second combo box - Songo 2012-04-05 22:20


0

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.

2012-06-04 22:38
by Sorin Adrian Carbunaru


0

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 .

2012-04-05 23:37
by Mouna Cheikhna
Ads