【问题标题】:Closing featherlight upon submitting form提交表单时关闭羽毛灯
【发布时间】:2015-08-09 16:20:19
【问题描述】:

我有一个 demo-employee.php 页面,它检索系统的所有用户以及可以执行的特定操作:

<td><table>
    <tr>
    <td><a href="edit-user.php?userid=<?php echo $userid ?> "><i class="fa fa-pencil-square-o"></i></a></td>
    <td><a href="demo-change-password.php?userid=<?php echo $userid ?>" data-featherlight><i class="fa fa-key"></i></a></td>**
    <td><a href="remove-user.php?userid=<?php echo $userid ?>" onclick="return confirmAction()"><i class="fa fa-trash-o"></i></a></td>
    </tr>
    </table>
    </td>**

我正在使用 data-featherlight 弹出页面 demo-change-passowrd.php,点击链接后用户会得到这个表单:

<form id="changePwd" name="formPwd" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" accept-charset="UTF-8"> 



 <p>Please fill all the mandatory (*) fields.</p>
    <div class="question">
    <input type="password" name="new_pwd"  pattern="^.*(?=.{6,})(?=.*[a-zA-Z])[a-zA-Z0-9]+$" title="Your new Password is required" required/>
    <label><?php echo "<font color='red'>New Password(*):</font>" ?></label>
    </div>
    <div class="question">
    <input type="password" name="confirm_pwd"  pattern="^.*(?=.{6,})(?=.*[a-zA-Z])[a-zA-Z0-9]+$" title="Confirm Password field is required" required/>
    <label><?php echo "<font color='red'>Confirm Password(*):</font>" ?></label>
    <span class="required" id="doesNotMatch"></span>
    </div>

<center>
<input type="submit" name="submit" onclick="checkPwdMatch();" onsubmit="return closeSelf(this);" value="Submit" />
<input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
</center>
</form>

我有一个方法来检查 pwd 是否匹配,并且在成功提交表单后,它应该使用附加在页面底部的此方法关闭

function closeSelf(f){
f.submit()
window.close();
}

我还把它从按钮移到了表单 onsubmit="return closeSelf(this);",仍然没有运气。提交表单后,它只停留在 demo-change-passowrd.php 上。我还用 window.location.replace 代替了 window.close() 来代替 demo-employeed 页面,也没有运气。有人可以帮忙吗,我做到了

$("#myform").submit(function(e) {

        //prevent Default functionality
        e.preventDefault();
window.close();

还是没有运气?请问我有什么遗漏吗?

【问题讨论】:

  • 我也试过用这个;好消息是它没有回显“您的密码已成功更改”,弹出页面保持不变:
  • 然后我把它改成 ,希望它会重定向员工页面,仍然没有运气
  • 我用这个运行了一个测试: 它确实会警告“调用 .submit() 的处理程序”,但我应该用 window.location.replace("demo-employee.php") 替换它,它就不会工作

标签: javascript php jquery forms


【解决方案1】:

我向form 添加了一个onsubmit 属性,该属性将调用关闭按钮(具有featherlight-close 类)上的“单击”。

&lt;form ... onsubmit="$('.featherlight-close').click()"&gt;

【讨论】:

    猜你喜欢
    • 2013-02-10
    • 2022-11-02
    • 1970-01-01
    • 2017-09-22
    • 2018-08-22
    • 1970-01-01
    • 1970-01-01
    • 2019-06-18
    • 2021-06-12
    相关资源
    最近更新 更多