-->

zend framework and jquery - attach event from serv

2020-07-31 11:31发布

问题:

I have a form I created with Zend_Form (or Zend_JQuery_Form now).

I have a select box in the form and I would like to do a call-back to the server when the user selects a value (to create dependent select boxes).

Is there any way to specify the "change" event code from the server side? or just to write the jquery client side myself?

Thanks.

回答1:

Yes. That is possible to add in the server side itself. While creating your form element, add the details for the onchange event like shown below.

$titleElement = $form->createElement('text', 'title', array(
'onchange' => 'alert(this.value);'
'label' => 'This is the title'
));