為什麼要使用HTML表單?因為要來收集使用者輸入資料,可以和Javascript和Asp來和使用者互動~
一個表單會有<form>...</form>
標籤包起來,再配合表單原件來做使用
action
:指定表單送出後資料要送去哪個網址method
:指定表單送出資料的方式,常見的有GET和POST兩種
GET和POST有什麼差別?
GET:主要設計是取得資料所以網址會變得很長,且包含所有傳送的資料安全性較差
POST:主要設計是傳遞資料且只顯示目標路徑,隱藏了傳送的具體內容所以安全性較好name
:表單名稱,一份 HTML 裡表單名稱不可重複
<input type="password" id="password" name="password" required>
<label for="city">選擇居住城市:</label>
<select id="city" name="city">
<option value="Taipei">台北</option>
<option value="Taichung">台中</option>
<option value="Kaohsiung" selected>高雄</option>
</select>
一個框框讓你點~
<input type="checkbox" id="agree" name="agree" value="yes" required>
<label for="agree">我同意會員條款</label>
一個按鈕
<button type="submit">註冊</button>
最常用的輸入框,可以用來輸入姓名
<label for="username">使用者名稱:</label>
<input type="text" id="username" name="username">