標籤:
form(表單),它是頁面與WEB伺服器互動過程中最重要的資訊來源,在網頁中的作用不可小視。負責擷取使用者填寫資料,並通過瀏覽器向伺服器傳送資料。
一個表單有三個基本組成部分:
表單標籤:這裡麵包含了處理表單的資料所用程式的URL以及資料提交到伺服器的方法,表單名等。
文法:<form action="伺服器程式URL(提交到給誰處理)" method=" get/post" enctype=" MIME資訊" target="文檔顯示方式" >表單詳細設定</form>
表單域:包括了文字框(text),密碼框(password),隱藏欄位(hidden),複選框(checkbox),單選框(radio),檔案上傳框(file),
多行文字框( 基本文法:<textarea name="" col="" row="" wrap="" ></textraea>)
下拉選擇框(基本文法:<select name=""><option value="" selected(表示預設選擇本項顯示在下拉式功能表上)>廣州</option></select)等。
表單按鈕:包括提交按鈕(submit),複位按鈕(reset),一般按鈕(button)
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><style> input,select,textarea{ margin-top: 15px; }</style><body><form action="login.html" method="post" target="_blank"><label for="user">使用者名稱:</label><input type="text" name="user" id="<user></user>" size="" maxlength="8" value="請輸入..."/><br><label for="password">密 碼:</label><input type="password" name="password" id="password" size="" maxlength="" value=""/><br><label for="checkbox">複選框:</label><input type="checkbox" name="" id="checkbox" value=""/><br><label for="radio">單選框:</label><input type="radio" name="" id="radio" value=""/><br><label for="hidden">隱藏欄位:</label><input type="hidden" name="" id="hidden" value=""/><br><label for="file">上傳檔案:</label><input type="file" name="" id="file"/><br><label for="sel">下拉式功能表:</label><select name="" id="sel"> <option value="2" > 上海</option> <option value="1" selected> 廣州市</option> <option value="3" > 深圳</option> <option value="4" > 北京</option></select><br><label for="ta">多行文字框:</label><br><textarea name="desc" cols="50" rows="10" wrap="" id="ta"></textarea><br><input type="submit" name="sub" value="這是提交按鈕"/><input type="reset" name="res" value="這是複位按鈕"/><input type="button" name="btn" value="這是普通按鈕"/><input type="image" name="img" src="btn.jpg"/></form> </body></html>
顯示的效果:
基礎的HTML表單