【发布时间】:2022-01-25 18:56:51
【问题描述】:
目前正在设置一个表单以在支付系统中创建新订单,当我单击表单中的任何按钮时,表单会提交。有谁知道可能是什么问题? 这是有问题的代码:
<form action="scripts/php/addorder.php" method="POST">
<script src="scripts/javascript/cookies.js"></script>
<script src="scripts/javascript/addproduct.js"></script>
<label>Choose Customer: </label>
<input type="text" value="" name="name" id="name" required readonly>
<button onclick ="window.open('customertable.php','popup','width=600,height=600');">Choose</button>
<br/>
<div id="products">
<label>Products: </label>
<br/>
ID: <input type="text" value=" " name="chosenproduct0" id="chosenproduct0" required readonly>
Name: <input type="text" value=" " name="chosenproduct0name" id="chosenproduct0name" required readonly>
Price: <input type="text" value=" " name="chosenproduct0price" id="chosenproduct0price" required readonly>
Quantity: <input type="number" value="1" name="chosenproduct0quantity" id="chosenproduct0quantity" required>
<button onclick ="findproduct('chosenproduct0');">Choose Product</button>
</div>
<br/>
<label>Discount: </label>
<input type="number" placeholder="0" name="discount" id="discount" step=".01" min="0">
<label>Total: </label>
<input type="number" value="0" name="total" id="total" readonly>
<button onclick="addproduct()">Add Product</button>
<br/>
<input type="submit" id="submit" value="Create New Order" class="button"/>
</form>
【问题讨论】:
-
这能回答你的问题吗? How can I submit a form using JavaScript?
-
这就是按钮的作用,默认情况下它们是
type="submit",如果你不指定任何不同的话。如果您不想这样做,请更改为type="button"。并始终检查您已经可以找到此信息的文档...developer.mozilla.org/en-US/docs/Web/HTML/Element/button。我假设您仍然希望最后一个“输入”按钮实际提交?
标签: javascript php html