为什么以下不起作用。它只需要我到index.php页面并切断“获取”数据
<div class="wrapper">
<form class="form-signin" method="post">
<h2 class="form-signin-heading">Customer Not Found</h2>
No customer was found matching <?=$_POST['phone'];?>.<br/>
You can create a new customer with this number, or search again<br/>
<button
class="btn btn-lg btn-primary btn-block"
id="createCust"
>
Create A New Customer
</button>
<button class="btn btn-lg btn-primary btn-block" type="submit" name="login">Search Again</button>
</form>
</div>
<script type="text/javascript">
document.getElementById("createCust").onclick = function () {
location.href = "index.php?proc=newCust&p=<?=$_SESSION['phone'];?>";
};
</script>
答案 0 :(得分:0)
正如@Teemu所说:
表单中按钮的默认操作是提交表单。一个 挂起的服务器调用将阻止对location.href的更改。定义 按钮作为按钮的类型。 -
我将“type”作为提交,将其更改为type =“button”解决了这个问题。