提交表格时关闭羽毛灯

时间:2015-05-27 14:04:44

标签: javascript php jquery forms

我有一个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>

我有一个检查pwdmatches的方法,并且在成功提交表单后,它应该用这个附加在页面底部的方法关闭

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

此外,我将此按钮从按钮移动到表格onsubmit =“return closeSelf(this);”,仍然没有运气。提交表单后,它会保留在demo-change-passowrd.php上。我还使用window.location.replace代替了window.close(),也没有运气。有人可以帮忙吗,我做了

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

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

还没运气?我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

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

<form ... onsubmit="$('.featherlight-close').click()">