我正在構建一個使用 HTML(也可以使用 javascript)收集學生資訊的調查表,并在網上找到了幾個示例,但似乎都沒有作業。調查表目前只選擇這些:

調查應該選擇所有選項(名字、姓氏、居住地、大學選擇、專業、校園參觀),我不知道如何解決這個問題。
這是調查和代碼:

<h3> Senior Survey </h3>
<div class="w3-container">
<script type="text/javascript">
console.log("Prospective student form is about to be displayed.");
</script>
<form method="post" action="mailto:[email protected]" method="GET" enctype="text/plain" name="seniorsurvey">
<table class="w3-table w3-blue" id="second-gradient">
<tr>
<td style="text-align: center";>
<p><b> Please enter your first and last names. </b></p>
<input type="text" id="firstname" maxlength="60" placeholder="First Name:"/>
<input type="text" id="lastname" maxlength="60" placeholder="Last Name:"/>
</td>
</tr>
<tr>
<td style="text-align: center";>
<p><b> Where do you live? </b></p>
<input type="radio" id="peru" name="radiobutton" value="Peru">
<label for="peru">Peru</label>
<input type="radio" id="southamerica" name="radiobutton" value="SA">
<label for="southamerica">South America</label>
<input type="radio" id="unitedstates" name="radiobutton" value="USA">
<label for="unitedstates">United States</label>
</td>
</tr>
<tr>
<td>
<fieldset style="text-align: center";>
<p><b> What were your other top college choices? </b></p>
<input type="checkbox" id="bentley" name="uni">
<label for="bentley">Bentley U.</label>
<input type="checkbox" id="brandeis" name="uni">
<label for="brandeis">Brandeis U.</label>
<input type="checkbox" id="boston" name="uni">
<label for="boston">Boston U.</label>
<input type="checkbox" id="babson" name="uni">
<label for="babson">Babson U.</label>
<input type="checkbox" id="northeastern" name="uni">
<label for="northeastern">Northeastern U.</label>
</fieldset>
</td>
</tr>
<tr>
<td style="text-align: center";>
<p><b> What is your prospective major? </b></p>
<select name="majors" id="majors">
<option value="un">undecided</option>
<option value="cis">Computer Information Systems</option>
<option value="fi">Finance</option>
<option value="acc">Accounting</option>
<option value="ci">Creative Industries</option>
<option value="mkt">Marketing</option>
</select>
<br>
</td>
</tr>
<tr>
<td style="text-align: center";>
<p><b> When do you plan to visit campus? </b></p>
<input type="date" id="start" name="visit-start" value="2021-10-25" min="2021-10-25" max="2030-12-31">
<br><br>
</td>
</tr>
<tr>
<td style="text-align: center";>
<button type="submit" value="Submit College Info"> Submit </button>
<button type="reset" value="Clear College Info"> Clear </button>
<br><br>
</td>
</tr>
</table>
</form>
</div>
uj5u.com熱心網友回復:
您的一些表單欄位,例如
<input type="text" id="firstname" maxlength="60" placeholder="First Name:"/>
沒有name引數,這是使資料正確發送到服務器的粘合劑。您需要將該行更改為:
<input type="text" name="firstname" id="firstname" maxlength="60" placeholder="First Name:"/>
基本上只是 name="firstname"在那里添加。你必須做同樣的事情,增加 name="lastname"了id="lastname"-input。
3<input type="radio"行都使用name="radiobutton"; 從技術上講,這沒有錯,但是考慮到背景關系,您可能希望將所有 3 個更改為name="country"或類似的內容。這 3 個應該是相同的(因為人們只能選擇這 3 個國家中的 1 個,而不是其中的 2 個或 3 個,也不能選擇 0 個)。
5<input type="checkbox"行都使用name="uni",這可能是錯誤的(盡管我實際上不能肯定地說)。人們可以選擇它們的任意組合。您可能希望將這些更改為 5 個不同的名稱(如name="uni_bentley"第一個,...),或者您可能希望將它們全部保持不變。也許兩者都嘗試一下,看看你喜歡哪兩個結果(提交時選擇幾個/所有的 uni)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/380328.html
標籤:javascript html 形式 邮政 民意调查
