gpt4 book ai didi

java - 通过javascript将自动生成的数字插入数据库表

转载 作者:行者123 更新时间:2023-11-30 00:20:21 26 4
gpt4 key购买 nike

我已经为我的网站创建了一个。我的表单发布到两个单独的表中,即:'members''users'

除了成员(member)类型'membershipnumber'下之外,我的表单似乎可以很好地输入到我的数据库中。我的成员(member)号是使用 JavaScript 自动生成的。

请有人帮助我并为我指出正确的方向,为什么这不起作用以及我如何让它工作。

<form action="receptionist.php" method="post">
<td align="center" style="background-color:lightblue;"><b>-Personal Information-<br></td> </b>
</p>
<tr>
<td align="left"> Last name: <input type="text" name="lastname"></td>
<td></td>
<td align="left"> Medical Information: <input type="text" name="medicalinformation"></td>
</tr>
<tr>
<td align="left"> First name: <input type="text" name="firstname"></td>
<td></td>
<td align="left">Membership Type: <select name="membershiptype" id="membershiptype">
<option value="">Select One</option>
<option value = "Gold">Gold</option>
<option value = "Silver">Silver</option>
</select></td>
</tr>
<tr>
<td align="left"> Date Of Birth: <input type="text" name="dateofbirth"><br></td>
<td></td>
<td align="left"> Gender:<input type ="radio" name="gender" value="Male"> Male
<input type ="radio" name="gender" value="Female"> Female<br>
</tr>
<td align="left">Membership Referral: <input type="text" name="membershipreferral"><br></td>
<td></td>
<td align="left"> Trainer Required: <input type ="radio" name="trainerrequired" value="Yes"> Yes
<input type ="radio" name="trainerrequired" value="NO"> No<br></td>

</tr>

<td align="left"> Membership Number:</td>
<td align="left" id="xyz"><input type="text" name="membershipnumber" disabled></td>
<script>
var num = Math.floor(Math.random() * 9000) + 1000;
document.getElementById("xyz").innerHTML=num;
</Script>

<td align="left"> Contract: <input type ="radio" required> Agree <br></td>
</tr>
<td align="left">
Please select contract duration
<select name="contract" id="contract">
<option value="">Select One</option>
<option value = "1 month">1 month</option>
<option value = "2 month">2 month</option>
<option value = "3 month">3 month</option>
<option value = "4 month">4 month</option>
<option value = "5 month">5 month</option>
<option value = "6 month">6 month</option>
<option value = "7 month">7 month</option>
<option value = "8 month">8 month</option>
<option value = "9 month">9 month</option>
<option value = "10 month">10 month</option>
<option value = "11 month">11 month</option>
<option value = "12 month">12 month</option>
</select><br></td>
</tr>
</tr>
</br>

<td align="center" style="background-color:lightblue;"><b>-Address-<br></td> </b>
</p>
</tr>
<td align="left">House Number/Street: <input type="text" name="housenumberstreet"><br></td>
<td></td>
<td align="left"> City: <input type="text" name="city"><br></td>
</tr>
<td align="left"> County: <input type="text" name="county"><br></td>
<td></td>
<td align="left"> Postcode: <input type="text" name="postcode"><br></td>
</tr>
<td align="left"> Tel: <input type="text" name="tel"><br></td>
<td></td>
<td align="left"> E Mail: <input type="text" name="email"><br></td>


</tr>
<td align="center" style="background-color:lightblue;"><b>-Billing-<br></td> </b>
</tr>
</p>
<td align="left"> Bank Branch: <input type="text" name="bankbranch"><br></td>
</tr>
<td align="left"> Card Holder Name: <input type="text" name="cardholdername"><br> </td>
</tr>
<td align="left">Card Number: <input type="text" name="cardnumber"><br></td>
<td align="left">Sort Code: <input type="text" name="sortcode"></td>

</tr>
<td align="left"><font size="3.2" color="red"><b>Valid From</font><br> </b>
Valid Month <select name="validmonth" id="validmonth" required>
<option value="">Select One</option>
<option value = "January">January</option>
<option value = "February">February</option>
<option value = "March">March</option>
<option value = "April">April</option>
<option value = "May">May</option>
<option value = "June">June</option>
<option value = "July">July</option>
<option value = "August">August</option>
<option value = "September">September</option>
<option value = "October">October</option>
<option value = "November">November</option>
<option value = "December">December</option>
</select>
Valid Year <select name="validyear" id="validyear" required>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>

</select><br></td>
</tr>
<td align="left"> <font size="3.2" color="red"><b>Expiry</font><br> </b>
Expiry Month <select name="expirymonth" id="expirymonth" required>
<option value="">Select One</option>
<option value = "January">January</option>
<option value = "February">February</option>
<option value = "March">March</option>
<option value = "April">April</option>
<option value = "May">May</option>
<option value = "June">June</option>
<option value = "July">July</option>
<option value = "August">August</option>
<option value = "September">September</option>
<option value = "October">October</option>
<option value = "November">November</option>
<option value = "December">December</option>
</select>
Expiry Year <select name="expiryyear" id="expiryyear" required>
<option value="2014">2014</option>
<option value="2013">2015</option>
<option value="2012">2016</option>
<option value="2011">2017</option>
<option value="2010">2018</option>
<option value="2009">2019</option>
<option value="2008">2020</option>
<option value="2007">2021</option>
</select><br></td>
</tr>
<td align="left"> Security Code: <input type="text" name="securitycode"><br></td>
</tr>

<td align="left"><p style="background-color:lightblue;">
Please double check entered information and tick box to proceed
<input type="radio" required></br></td>
</tr>
<td align="left"> <input type="submit"></td>
</form>

最佳答案

你只需替换

<td align="left" id="xyz"><input type="text" name="membershipnumber" disabled></td> 
this line to
<td align="left"><input type="text" id="xyz" name="membershipnumber" disabled></td>

这一行。

您的代码片段一切正常。

希望对您有帮助。

关于java - 通过javascript将自动生成的数字插入数据库表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23297474/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com