我想要一个供员工输入订单ID的简单表格。该ID将通过第二个输入进行验证。验证通过后,它将通过服务器上的insert.php
传递到数据库。
以下是我到目前为止所写的内容。我很困惑如何在成功检查时推送数据或在失败时清除表单。
<script type="text/javascript" language="JavaScript">
<!--
//--------------------------------
// This code compares two fields in a form and submit it
// if they're the same, or not if they're different.
//--------------------------------
function checkid(theForm) {
if (theForm.orderid1.value != theForm.orderid2.value)
{
alert('The two values don\'t match! Please check!');
return false;
} else {
return true;
}
}
//-->
</script>
<form action="../" onsubmit="return checkid(this);">
<form action="insert.php" method="post">
<p> Enter the compleated Order ID<br>
<input type="TEXT" name="orderid1" size="20" maxlength="20">
<br>
Please Confirm the order ID!
<br>
<input type="TEXT" name="orderid2" size="20" maxlength="20">
<br>
<input type="SUBMIT" value="Compleate Order!"></p>
</form>
答案 0 :(得分:1)
无论如何,这就是您的答案。
<script type="text/javascript" language="JavaScript">
<!--
//--------------------------------
// This code compares two fields in a form and submit it
// if they're the same, or not if they're different.
//--------------------------------
function checkid(theForm) {
if (theForm.orderid1.value != theForm.orderid2.value)
{
alert('The two values don\'t match! Please check!');
return false;
} else {
return true;
}
}
//-->
</script>
<form action="insert.php" onsubmit="return checkid(this);" method="post">
<p> Enter the compleated Order ID<br>
<input type="TEXT" name="orderid1" size="20" maxlength="20">
<br>
Please Confirm the order ID!
<br>
<input type="TEXT" name="orderid2" size="20" maxlength="20">
<br>
<input type="SUBMIT" value="Compleate Order!"></p>
</form>