views:

57

answers:

1

Hi,

Could you please help me rosolve my troubling matter. I used Zend_Form to create what I needed. However as I have relations many to many i decided to present multiple choices via checkboxes. Unfortunately range of these checkboxes depends on select field available in form.

I would like to change visible/availabe checkboxes depending on select option choosen.

I found that it should be possible to use javascript however I've got no idea how to take advantege of it in form based on Zend_Form.

Could you suggest possible solution?

Thank you in advance.

Kind Regards,

A: 

Add onchange attribute to the select like this

$form->addElement('select', 'select', array(
  'label'       => 'select',
  'multiOptions => array('zero', 'one'),
  'onchange'    => 'displayCheckboxes(this)'
));

After that implement a simple js function to display whatever you need

function displayCheckboxes(obj) {
  // js code here
}
michal kralik