DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> HTML基礎知識 >> HTML和Xhtml >> HTML Form表單元素全面了解
HTML Form表單元素全面了解
編輯:HTML和Xhtml     

如下所示:

XML/HTML Code復制內容到剪貼板
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2.   
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4. <head>  
  5.     <title>注冊表單</title>  
  6. </head>  
  7. <body>  
  8.     <form action="DoFormAction.htm">  
  9.         <fieldset style="width=800px">                                                              <!--套住注冊表格的邊框-->  
  10.         <legend>請輸入如下的信息然後進行注冊</legend>  
  11.         <table cellspacing="0px" cellpadding="6px" border="1px" bordercolor="black" align="center" width="600px">  
  12.             <tr>  
  13.                 <td align="right">用戶名:</td>                                   <!--文本框-->  
  14.                 <td><input type="text" size="20" style="width:150px" /></td>  
  15.             </tr>  
  16.             <tr>  
  17.                 <td align="right">密碼:</td>                                     <!--密碼框-->  
  18.                 <td><input type="password" size="20" style="width:150px" /></td>  
  19.             </tr>  
  20.             <tr>  
  21.                 <td align="right">確認密碼:</td>  
  22.                 <td><input type="password" size="20" style="width:150px" /></td>  
  23.             </tr>  
  24.             <tr>  
  25.                 <td align="right">性別:</td>                                      <!--單選框-->  
  26.                 <td>  
  27.                     <input type="radio" checked="checked" name="sex1" value="男" />男    
  28.                     <input type="radio" name="sex1" value="女" />女   
  29.                 </td>  
  30.             </tr>  
  31.             <tr>  
  32.                 <td align="right">性別(可以點文字選擇):</td>  
  33.                 <td>  
  34.                     <fieldset style="width:150px">                              <!--表單外框,也可以通過css設置寬度-->  
  35.                     <legend>請選擇性別</legend>  
  36.                         <input type="radio" checked="checked" name="sex2" value="男" id="man" />  
  37.                         <label for="man">男</label>  
  38.                         <input type="radio" name="sex2" value="女" id="woman" />  
  39.                         <label for="woman">女</label>  
  40.                     </fieldset>  
  41.                 </td>  
  42.             </tr>  
  43.             <tr>  
  44.                 <td align="right">城市:</td>                                    <!--下拉框-->  
  45.                 <td>  
  46.                     <select name="city">  
  47.                         <option value="北京">北京</option>  
  48.                         <option value="深圳">深圳</option>  
  49.                         <option value="上海">上海</option>  
  50.                         <option value="南昌" selected="selected">南昌</option>  <!--默認選擇南昌-->  
  51.                     </select>  
  52.                 </td>  
  53.             </tr>  
  54.             <tr>  
  55.                 <td align="right">城市所在區域:</td>  
  56.                 <td>  
  57.                     <select name="area">            
  58.                         <optgroup label="北京">                                <!--下拉框分組顯示-->  
  59.                             <option value="朝陽區">朝陽區</option>  
  60.                             <option value="海澱區">海澱區</option>  
  61.                             <option value="其他區">其他區</option>  
  62.                         </optgroup>  
  63.                         <optgroup label="南昌">  
  64.                             <option value="東湖區">東湖區</option>  
  65.                             <option value="西湖區">西湖區</option>  
  66.                             <option value="青山湖區">青山湖區</option>                               
  67.                         </optgroup>  
  68.                     </select>  
  69.                 </td>  
  70.             </tr>  
  71.             <tr>  
  72.                 <td align="right">交友目標:</td>  
  73.                 <td>  
  74.                     <select name="target" size="3" multiple="multiple">        <!--列表框-->         
  75.                         <option value="同行" selected="selected">同行</option>  
  76.                         <option value="普通朋友">普通朋友</option>  
  77.                         <option value="愛人">愛人</option>  
  78.                     </select>  
  79.                 </td>  
  80.             </tr>  
  81.             <tr>  
  82.                 <td align="right">愛好:</td>  
  83.                 <td>  
  84.                                                                             <!--復選框,注意name屬性設置一樣,分組-->      
  85.                     <input type="checkbox" name="love" value="足球" />足球   
  86.                     <input type="checkbox" name="love" value="藍球" />藍球   
  87.                     <input type="checkbox" name="love" value="乒乓球" />乒乓球   
  88.                 </td>  
  89.             </tr>  
  90.             <tr>  
  91.                 <td align="right">照片上傳:</td>  
  92.                 <td>  
  93.                                                                             <!--文件選擇框-->      
  94.                     <input type="file" name="myPic" />  
  95.                 </td>  
  96.             </tr>  
  97.             <tr>  
  98.                 <td align="right">自我介紹:</td>  
  99.                 <td>  
  100.                                                                             <!--多行文本框-->      
  101.                     <textarea rows="5" cols="50">  
  102.                     </textarea>  
  103.                 </td>  
  104.             </tr>  
  105.             <tr>  
  106.                 <td align="center" colspan="2">  
  107.                     <input type="submit" value="確定" />  
  108.                     <input type="reset" value="清空" />                       
  109.                     <input type="image" src="../images/btnreg.png" onclick="alert('hello')" />      <!--演示圖片按鈕(會提交數據,類似submit)  
  110.                                                                                                     -->  
  111.                 </td>  
  112.             </tr>  
  113.         </table>  
  114.         </fieldset>  
  115.     </form>  
  116. </body>  
  117. </html>  

以上就是小編為大家帶來的HTML Form表單元素全面了解的全部內容了,希望對大家有所幫助,多多支持腳本之家~

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved