我使用zend表单来创建表单。我也在使用mootools for javascript。
$this->addElement('radio', 'alone', array(
'label' => 'Are you going to be taking part with anyone else?',
'required' => true,
'onClick' => 'showFields();',
'multiOptions' => array(
'yes' => 'Yes',
'no' => 'No'
))
);
目前,如果选择任何选项,onclick事件将起作用。我如何才能让它被选中?
答案 0 :(得分:1)
你可以试试这个......
$this->addElement('radio', 'alone', array(
'label' => 'Are you going to be taking part with anyone else?',
'required' => true,
'onClick' => 'showFields(this);',
'multiOptions' => array(
'yes' => 'Yes',
'no' => 'No'
))
);
在你的功能......
function showFields(elem)
{
if(elem.value != 'yes')
return false;
// rest of the code
}