1.表單標簽 及 表單屬性
·表單標簽是 :<form>
·表單屬性有:action 和 method;
???·action屬性:規定向何處發送表單數據。
?·method屬性:規定用什么方法發送數據。(get和post)
?get:在發送的url后面拼接表單數據,明文顯示表單數據的內容,url的長度有限制。
?post:在消息體/請求體中傳遞,參數大小無限制。
2.表單項 及 屬性
表單標簽中常包括三種表單項標簽:input、select、textarea
????????·input:定義表單項,通過type屬性控制輸入
?????????????type屬性的值有:
???????????????????① text:默認值,定義單行的輸入字段
② password:定義密碼字段
③ radio:單選按鈕,name屬性相同表示在一個備選圈中,value屬性不同,表示各自的選項;如果最外層嵌套label標簽,這樣不用精準點擊方格,點擊文字部分也可選中
④ checkbox:復選
⑤ file:文件上傳
⑥ data/time/datatime-local:定義日期、時間、日期和時間
⑦ number:數字輸入框
⑧ email:郵件輸入框
⑨ hidden:隱藏域
⑩ submit/reset/button:提交、重置、可點擊按鈕,value屬性的值會展示在按鈕上-------------------------------------------------------------------------------------------------------------------------
????????·select:下拉列表,標簽?option?定義列表項
????????????????形式寫法:
-------------------------------------------------------------------------------------------------------------------------
????????·textarea:定義文本域
????????????????常見屬性的值有:cols和row
????????????????????????① cols:一行最多有幾個字符
② rows:默認可以寫幾行
3.表單效果展示:
<table action="" methods="get"><h1 style="text-align: center;">基礎信息表</h1>姓名:<input type="text" name="name"> <br> 密碼:<input type="password" name="password"> <br> 性別:<input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女 <br>愛好: <label><input type="checkbox" name="love" value="1"> 唱歌</label> <label><input type="checkbox" name="love" value="2"> 跳舞</label> <label><input type="checkbox" name="love" value="3"> 繪畫</label> <br>上傳簡歷pdf:<input type="file"> <br>選擇日期 和 時間:<input type="datetime-local"><br>年齡:<input type="number"><br>郵件:<input type="email"><br>學歷:<select name="degree"><option value="1">-----下拉選擇學歷-----</option><option value="2">高中</option><option value="3">本科</option><option value="4">研究生</option></select><br>其他留言:<textarea cols="30" rows="6"></textarea><br><br><input type="button" name="button" value="按鈕"> <input type="reset" name="reset" value="重置"> <input type="submit" name="submit" value="提交"></table>
整個代碼:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>表單</title><style>span{margin-left: 60px;color: darkblue;}.div1{width: 380px;height: 600px;background-color:lightgoldenrodyellow;margin-left: 100px;padding: 30px ;line-height: 40px;}div{margin-left: 70px;}</style></head><body><h2>1.表單標簽 及 表單屬性</h2><p>·表單標簽是 :<b>form</b><br>·表單屬性有:action 和 method;<br> <b>·action屬性:</b>規定向何處發送表單數據。<br> <b>·method屬性:</b>規定用什么方法發送數據。(get和post)<br> get:在發送的url后面拼接表單數據,明文顯示表單數據的內容,url的長度有限制。<br> post:在消息體/請求體中傳遞,參數大小無限制。</p><h2>2.表單項 及 屬性</h2><p>表單標簽中常包括三種表單項標簽:<b>input、select、textarea </b> </p><p style="text-indent: 30px;"><b style="color: blue;">·input:</b>定義表單項,通過type屬性控制輸入</p><span>type屬性的值有:</span><div> ① text:默認值,定義單行的輸入字段<br>② password:定義密碼字段<br>③ radio:單選按鈕,name屬性相同表示在一個備選圈中,value屬性不同,表示各自的選項;如果最外層嵌套label標簽,這樣不用精準點擊方格,點擊文字部分也可選中<br>④ checkbox:復選<br>⑤ file:文件上傳<br>⑥ data/time/datatime-local:定義日期、時間、日期和時間<br>⑦ number:數字輸入框<br>⑧ email:郵件輸入框<br>⑨ hidden:隱藏域<br>⑩ submit/reset/button:提交、重置、可點擊按鈕,value屬性的值會展示在按鈕上</div><p style="text-indent: 30px;"><b style="color: blue;">·select:</b>下拉列表,標簽 <b>option</b> 定義列表項</p><span>形式寫法:</span><br><div> <img src="select.png" width="400px"> </div><p style="text-indent: 30px;"><b style="color: blue;">·textarea:</b>定義文本域</p><span>常見屬性的值有:<b>cols和row</b></span><div>① cols:一行最多有幾個字符<br>② rows:默認可以寫幾行</div><h2>3.效果展示:</h2><div class="div1"><table action="" methods="get"><h1 style="text-align: center;">基礎信息表</h1>姓名:<input type="text" name="name"> <br> 密碼:<input type="password" name="password"> <br> 性別:<input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女 <br>愛好: <label><input type="checkbox" name="love" value="1"> 唱歌</label> <label><input type="checkbox" name="love" value="2"> 跳舞</label> <label><input type="checkbox" name="love" value="3"> 繪畫</label> <br>上傳簡歷pdf:<input type="file"> <br>選擇日期 和 時間:<input type="datetime-local"><br>年齡:<input type="number"><br>郵件:<input type="email"><br>學歷:<select name="degree"><option value="1">-----下拉選擇學歷-----</option><option value="2">高中</option><option value="3">本科</option><option value="4">研究生</option></select><br>其他留言:<textarea cols="30" rows="6"></textarea><br><br><input type="button" name="button" value="按鈕"> <input type="reset" name="reset" value="重置"> <input type="submit" name="submit" value="提交"></table></div></body>
</html>