所以我有一个表格,提交时需要确认.我正在使用Javascript确认提示.但是,如果有人点击取消,我不希望它刷新.我认为放一个空的其他声明会这样做,但看起来我错了.
不确定我需要做什么来确保如果有人在弹出窗口上按下取消它不会刷新.
function postConfirm() {
if (confirm('You will not have another chance after submitting to view your post. Please make sure it is exactly how you want it before continuing. ')) {
yourformelement.submit();
} else {
}
}
Run Code Online (Sandbox Code Playgroud)
<div id="uploadForm">
<center>
<form enctype="multipart/form-data" action="functions/post_upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="99999999" />
<div><textarea id="text" cols="70" rows="15" name="entry"></textarea></div>
<p> Attach an image to this memory!</p>
<input name="userfile" type="file"><br>
<input type="submit" value="Submit" class="blueButton" onclick="postConfirm()"/></div>
</form></center>
</div>
Run Code Online (Sandbox Code Playgroud)
更改:
onclick="postConfirm()"
Run Code Online (Sandbox Code Playgroud)
至
onclick="return postConfirm()"
Run Code Online (Sandbox Code Playgroud)
并在你的功能,使其他:
else {
return false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4227 次 |
| 最近记录: |