基礎的HTML表單

來源:互聯網
上載者:User

標籤:

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表單

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.