我对表单提交有疑问。我在 processFabrication.php 上有这个简单的表单来提交所有变量,然后在另一个名为 processExceededQty.php
的页面中将其处理到数据库Co,在 processFabrication.php 中,我有
echo "<form action='processExceededQty.php' method='post'>";
当我点击submit
时,会转到 processExceededQty.php 。
我的目标是,
非常感谢任何帮助。
答案 0 :(得分:3)
javascript
中的类似内容:
function doSubmit(){
if (confirm('Are you sure you want to submit?')) {
// yes
return true;
} else {
// Do nothing!
return false
}
}
在onsubmit
:
html
添加到您的表单中
<form action='processExceededQty.php' method='post' onsubmit='doSumit()'>
答案 1 :(得分:2)
除了@ N0M3答案。
在<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
你的功能稍有改变
function doSubmit(){
if (confirm('Are you sure you want to submit?')) {
// yes
$(this).submit(function(e){
e.preventDefault();
});
jQuery.ajax({
url : 'processExceededQty.php',
data : {'username':username}, // where first 'username' is your field name, and second one is your field's value
method: 'post',
success: function(data) {
// data is variable which has return data from `processExceededQty.php`
// do whatever you want with data
}
});
} else {
// Do nothing!
return false;
}
}
答案 2 :(得分:0)
使用&#34; onsubmit&#34;上的功能如下形式,
<form action='processExceededQty.php' method='post' onsubmit='reutrn show_pop_up()'>
在脚本上你可以写下面的
<script>
function show_pop_up()
{
// show pop up
if(op_up_return =="Yes")
return true;
else
return false;
}
</script>
希望这会有所帮助。