就像我在標題中所說的那樣,我試圖從下面的表格中得到我的結果:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script>
/* Struggling with this part */
</script>
</head>
<body>
<h1 style="color:#e6e8e8">Video Game Form</h1>
<form id="form" class="form">
<div class = "form-control">
<label>All Time Favorite Game:</label>
<input name="allgame" id="allgame" type="text" placeholder="Enter your favorite game">
<label>Favorite Free Game:</label>
<select name="freegame" id ="freegame">
<option>Select your favorite game</option>
<option>Fortnite</option>
<option>Apex Legends</option>
<option>Call of Duty: Warzone</option>
<option>Valorant</option>
<option>Rocket League</option>
</select>
</div>
<div class="form-control">
<label>More games you may play
<small>(Check all that apply)</small>
</label>
<label>
<input type="checkbox"
name="inp">Minecraft</input></label>
<label>
<input type="checkbox"
name="inp">GTA 5</input></label>
<label>
<input type="checkbox"
name="inp">Call Of Duty</input></label>
<label>
<input type="checkbox"
name="inp">Fortnite</input></label>
<label>
<input type="checkbox"
name="inp">Valorant</input></label>
<label>
<input type="checkbox"
name="inp">League of Legends</input></label>
<label>
<input type="checkbox"
name="inp">Rocket League</input></label>
<label>
<input type="checkbox"
name="inp">Elden Ring</input></label>
<label>
<input type="checkbox"
name="inp">Zelda</input></label>
<label>
<input type="checkbox"
name="inp">Other...</input></label>
</div>
<button type="submit" value="button" class="neon-button">
Submit
</button>
</form>
</body>
</html>
這是我正在學習網路開發的基本形式,但是我被困在這里。如果有人不介意幫助我獲取結果并將其添加到與 HTML 和 CSS 位于同一目錄中的文本檔案中,那將非常有用。
uj5u.com熱心網友回復:
在您的<script>標簽中,您需要為表單添加一個action或在單擊按鈕時手動獲取每個input元素select的值。但是,為了將結果寫入文本檔案,您需要在服務器端提供一些東西。客戶端 JS 不提供寫入服務器端檔案的實用程式,因為這是不可能實作的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/484847.html
標籤:javascript html css
上一篇:比較2個陣列,如果滿足條件則推送
