我为我的网站创建了一个。我的表单分为两个单独的表,即:'members'
和'users'
除了会员类型 'membershipnumber'
之外,我的表单似乎输入到我的数据库中。我的会员编号是使用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>
答案 0 :(得分:0)
你只需要替换
<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>
这一行。
您的代码段的所有内容都可以。
希望它对你有所帮助。
答案 1 :(得分:0)
我相信以下帖子可能会回答您的问题:reading innerHTML of HTML form with VALUE attribute (& its value) of INPUT tags。
简而言之:使用&#34; document.getElementById(&#34; xyz&#34;)。setAttribute(&#34; value&#34;,num);&#34;显式设置value属性。应该管用。有关innerHTML无法工作的详细信息,请参阅上述帖子。希望它有所帮助。