fvg*_*vgs 3 javascript post get form-submit onsubmit
我有一个简单的表单,其中包含一个隐藏的输入字段和一个提交按钮.当用户单击提交按钮时,我希望它首先运行带有confirm()函数的JavaScript函数.根据用户是否点击"确定"或"取消",我希望表单提交或不提交.如何成功将点击功能分配给提交按钮,并使其如上所述工作?
function confirmDelete() {
var del = confirm("Are you sure you wish to delete this post?");
if (del)
//continue and submit the form
else
//the form should not be submitted
}
Run Code Online (Sandbox Code Playgroud)
这是表格:
<form action="/delete/" method="post">
<input type="hidden" name="path" value="'.$path.'" />
</form>
Run Code Online (Sandbox Code Playgroud)
我意识到我可以完全废弃该表单并将隐藏变量作为GET变量传递给/ delete/page,但出于安全原因,我更倾向于使用POST变量.
Nie*_*sol 10
这就足够了:
<input type="submit" value="Delete" onClick="return confirm('Are you sure?');" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6925 次 |
| 最近记录: |