Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 验证数据并发布到mysql数据库的简单表单_Javascript_Java_Html - Fatal编程技术网

Javascript 验证数据并发布到mysql数据库的简单表单

Javascript 验证数据并发布到mysql数据库的简单表单,javascript,java,html,Javascript,Java,Html,我想要一个员工输入订单ID的简单表单。该ID将通过第二次输入进行验证。验证后,它将通过服务器上的insert.php传递到数据库 以下是我到目前为止所写的内容。如何在成功检查时推送数据,或在失败时清除表单,这让我感到困惑 <script type="text/javascript" language="JavaScript"> <!-- //-------------------------------- // This code compares two fields in

我想要一个员工输入订单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>

无论如何,这是你的答案

<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>

查看下面的问答,了解使用JavaScript发布的示例:为什么有2个?表单操作=../onsubmit=返回checkidthis;>这是什么?