0
我已经使用Zend框架2创建的表单对象上的多个选择框创建多个选择框:访问ZF2使用javascript
$contacts = new Element\Select('contacts');
$contacts->setLabel('All Contacts')
->setAttribute('name', 'contacts')
->setAttribute('multiple', 'multiple')
->setAttribute('size', 10)
->setOptions(array('options' => $users));
我想执行一些JavaScript当按下表单上的按钮:
$moveAllRight = new Element\Button('moveAllRight');
$moveAllRight->setLabel('Move All ->')
->setAttribute('value', 'Move All ->')
->setAttribute('onClick', 'moveAll(this.form.contacts,this.form.newContacts)');
不幸的是,当页面被创建的多个选择元件的名称附加用[]:
<select name="contacts[]" multiple="multiple" size="10">
我已经试过了JS函数调用中改变名称:
->setAttribute('onClick', 'moveAll(this.form.contacts[],this.form.newContacts[])');
,但我现在仍然没有任何运气得到它的工作。如果我从选择框中删除多个选项,它将起作用,但如果可能的话,我想使用多个选择框。有没有办法使这项工作?s