-1

这是我的表单页面,我想将此表单隐藏在链接或称为更改密码的按钮下,一旦用户单击它,它必须显示此表单。任何帮助,将不胜感激。

           <form action="#buildurl('user.change_password')#" method="post">
                <input type="hidden" name="email" id="email" value="#session.auth.email#">

                <div class="control-group">
                    <label class="label-control" for="password">Enter current password</label>
                    <div class="controls">
                         <input type="password" name="password" id="password" >
                    </div>
                </div>

                <div class="control-group">
                    <label class="label-control" for="password_new">Enter New password</label>
                    <div class="controls">
                         <input type="password" name="password_new" id="password_new" >
                    </div>
                 </div>                 

                <div class="control-group">
                    <label class="label-control" for="password_confirm">Enter confirm password</label>
                    <div class="controls">
                         <input type="password" name="password_confirm" id="password_confirm" >
                    </div>
                 </div>

                <div>
                    <button type="submit" name="submit_password" id="submit_password" class="btn btn-primary">Submit</button>
                </div>
             </form>
4

2 回答 2

3

你想要这个吗:DEMO HERE,如果它被隐藏,它将显示,否则,它将被隐藏。我建议在您的表单中添加 id 并用您'form'的 jQuery 代码替换#id,以避免在您有多个表单时出现问题。

查询:

<script type='text/javascript'>
 $('form').hide();//hide initially
 $("#showButton").click(function(e){
   $('form ').toggle('slow');//or just show instead of toggle

 });
</script>

<head>在html 页面的代码中添加 jQuery 文件:

<script type='text/javascript'src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
于 2013-09-16T10:59:43.973 回答
0

提供您的表单和按钮 ID。然后:

CSS

#yourForm { display: none; }

JS

$(document).on('click', '#changePassword', function () {
  $('#yourForm').show();
});
于 2013-09-16T11:01:28.200 回答