在PHP javascript window.location.href无法在提交按钮上工作? [英] in php javascript window.location.href not working on submit button?
问题描述
在PHP中,JavaScript window.location.href
在submit
按钮上不起作用.问题在于功能order()
不在提交按钮上.我也尝试过alert('');
消息.
In PHP JavaScript window.location.href
is not working on submit
button. The problem is that function order()
is not going on submit button. I have tried alert('');
message also.
我想要在提交订单按钮时提交表单,然后将用户重定向到login.php
I want when order button submitted, then form submits and user is redirected to login.php
<script type="text/javascript">
function order() {
var sStr1 = "login.php";
window.location.href = sStr1;
return false;
}
</script>
<input type="submit" class="button4" name="order" id="order" value="Place Order" onclick="order()" >
推荐答案
您必须在服务器端代码中添加重定向脚本.表单必须具有操作URL,以便默认情况下将其提交到URL(即,没有您的 order()函数).在该操作网址中检查表单数据是否由
You must add the redirect script in your server side code. Form must have a action url so that it will be submitted to the url by default submit click (ie, without your order() function). Inside that action url check if form data is recieved by
if(isset($_POST['order']))
并根据需要将用户重定向到该条件.
and redirect the user inside that condtion as u need.
这篇关于在PHP javascript window.location.href无法在提交按钮上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!