繁体   English   中英

href似乎不起作用

[英]href does not seem to work

为什么以下不起作用。 它只需要我到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>

正如@Teemu所述:

表单中按钮的默认操作是提交表单。 挂起的服务器调用将阻止对location.href的更改。 将按钮定义为按钮类型。 -

我把“类型”作为提交,将其更改为type =“button”解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM