0

我已经通过在 zend 中选中复选框为这两个元素编写了隐藏和显示脚本,但是值 1 将被发送到函数以进行选中和取消选中,因此它只显示元素但不隐藏元素。如何解决?

$this->addElement('checkbox', 'Change_Password',
    array('decorators' => $this->elementDecoratorsTr ,'label' => 'Want to Set password ? :',
    'required' => false,
    'onchange' => 'passwordShow(this.value)',
        'Options' => array(
            'checkbx1'  => 'checkbx1'),
    ));

    $this->addElement('Password', 'User_Password',array(
    'decorators' => $this->elementDecoratorsTr,
    'label' => 'Password:',
    'style' =>  'display:none;',
    'required' => false,
    'filters' => array('StringTrim'),
        'validators' => array(array(
        'validator' => 'StringLength')) 
    ));

    $this->addElement('Password', 'Confirm_Password',array(
    'decorators' => $this->elementDecoratorsTr,
    'label' => 'Confirm Password:',
    'style' =>  'display:none;',
    'required' => false,
    'filters' => array('StringTrim'),
        'validators' => array(array(
        'validator' => 'StringLength')) 
    ));

这是我隐藏和显示两个元素的脚本User_Password函数Confirm_Password

<script>

    function passwordShow(password)
    {
        alert(password);
        if(password)
        {
             $("#User_Password").show();
             $("#Confirm_Password").show();
        }
        else
        {
             $("#User_Password").hide();
             $("#Confirm_Password").hide();
        }
    }

    </script>
4

0 回答 0