Html中form標簽的定義與應用


        <form>標簽用於輸入創建html表單。

          form表單能包含input元素,根本type輸入的不同值,作用各不相同。比如文本字段、單選框、復選框和提交按鈕等等。

          1、form表單的屬性有

             a、action-- 跳轉指定的路徑

             b、 target 打開頁面的方式 分為

                  _self 在本頁面打開

                   _black 在新空白頁面打開

              c、method 傳輸的方式

                   get 顯性

                   post 隱形

               

<form action="https://www.baidu.com" method="get" target="_blank">            
            <input type="submit" name="" id="" value="跳轉到百度"  />
        </form>

   效果 :點擊,在新頁面打開 https://www.baidu.com 。

             文本類輸入

            主要用 <input type="  "   name=" "  value=" " />來完成

             文本框輸入  <input type="  text"   name=" "  value=" " />來完成

             密碼框輸入  <input type="password "   name=" "  value=" " />來完成

             隱藏域         <input type="hidden "   name=" "  value=" " />來完成   此部分不被用戶可見

             多文本輸入   <textarea   cols=" "  rows=" " name=" "></textarea>

用戶<input type="text" name="" id="" value="" /><br/>
        密碼<input type="password" name="" /><br />
        隱藏域:該區域內容不被用戶可見<input type="hidden" name=""/><br/>
        個人簡介<textarea cols="20" rows="3" name=""></textarea>

  運行實例如右圖:                      

                選擇類菜單

            單選框: <input type="radio" name=" " value=" "/>   有屬性checked="checked"為默認選擇

             

<form>
                   男性:<input type="radio" name="sex" value="male" checked="checked"/><br />
                   女性:<input type="radio" name="sex" value="female"/>
        
                       </form>

  運行實例==                      

            復選框: <input type="checkbox" name="  ">    有屬性checked="checked"為默認選擇

   

<form>
                           愛好:<input type="checkbox" name="抽煙" id="" value="抽煙" />抽煙
                                 <input type="checkbox" name="美食" id="" value="美食" checked="checked"/>美食
                                 <input type="checkbox" name="散步" id="" value="散步" />散步
                       </form>

運行實例:        

            下拉列表:<select name=''><option value=''></option></select>   有屬性selected="selected"為默認選擇

<form>
                           <h4>文明古國</h4>
                           <select name="文明古國">
                               <option value="aiji">埃及</option>
                               <option value="zhongguo" selected="selected">中國</option>
                               <option value="yindu">印度</option>
                               <option value="babilun">巴比倫</option>
                           </select>
                       </form>

運行實例:     

            文件  :  < input type="file" name="" id="" value="" />

<from>
                    <input type="file" name="" id="" value="" />
                </from>

運行實例: 

    其他屬性:

|--------readonly='readonly' 只讀 能傳值
|--------disabled='disabled' 不可用 不能傳值
|--------checked='checked' 單選與多選的默認選中
|--------selected='selected' 下拉的默認選中

             

             

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM