html(五) -- 表單標籤

來源:互聯網
上載者:User

標籤:post   nbsp   head   border   tab   程式碼範例   body   man   value   

表單標籤: 表單標籤的作用是用於提交資料給伺服器的。

表單標籤的根標籤是<form>標籤

常用的屬性:
    action: 該屬性是用於指定提交資料的地址。
    method: 指定表單的提交方式。
            get : 預設使用的提交方式。  提交的資料會顯示在地址欄上。
            post :  提交的資料不會顯示在地址欄上。
注意: 表單項的資料如果需要提交到伺服器上面,那麼表單項必須要有name的屬性值。

程式碼範例:

 1 <!DOCTYPE html> 2 <html> 3     <head> 4         <meta charset="UTF-8"> 5         <title>表單標籤</title> 6     </head> 7     <body> 8          9         <form action="http://www.baidu.com" method="get">10         <table border="1" width="400" height="300">11             <tr>12                 <td>使用者名稱</td>13                 <!-- 文本輸入框 單行-->14                 <td><input name="userName" type="text"/></td>15             </tr>16             <tr>17                 <td>密碼</td>18                 <!-- 密碼框 -->19                 <td><input name="password" type="password"/></td>20             </tr>21             <tr>22                 <td>性別</td>23                 <!-- 單選框 -->24                 <td>男<input checked="true" value="man"  name="sex" type="radio"/>   女<input name="sex" value="woman" type="radio"/></td>25             </tr>26             <tr>27                 <td>興趣愛好</td>28                 <!-- 複選框  同一組的複選框name的屬性值要一致  -->29                 <td>java <input value="java" name="hobit"  checked="checked" type="checkbox" />javascript <input type="checkbox" value="javascript" name="hobit" />android <input value="android" name="hobit" type="checkbox" /></td>30             </tr>31             <tr>32                 <td>城市</td>33                 <!-- 下拉框  -->34                 <td><select name="city">    35                     <option value="BJ">北京</option>36                     <option value="SH">上海</option>37                     <option value="GZ">廣州</option>38                     <option value="SZ">深圳</option>39                     </select>40                 </td>41             </tr>42             <tr>43                 <td>大頭照</td>44                 <!-- 檔案上傳框  -->45                 <td><input name="image" type="file" /></td>46             </tr>47             <tr>48                 <td>簡歷</td>49                 <!-- 文本域   -->50                 <td><textarea  name="intro" rows="10" cols="30"></textarea></td>51             </tr>52             <tr>53                 54                 <td colspan="2" align="center">55                     <!-- 提交按鈕  -->56                     <input type="submit" value="註冊"/>57                     <!--  重設按鈕 -->58                     <input type="reset" value="重設"/>59                 </td>60             </tr>61     </table>62     </form>63     64     </body>65 </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.