HTML表單設計

<form></form>定義表單。javascript

基本格式:<form action=」服務器端地址」 name=」表單名稱」 method=」post/get」></form>html

get方式:get方式提交時,會將表單的內容附加在URL的後面,因此限制了提交的內容長度,不超過8192個字符,且不具有保密性。java

post方式:post方式提交時,將表單中的數據一併包含在表單主體中,一塊兒傳送到服務器中處理,沒有數據大小限制。服務器

action:表單數據的處理程序的URL地址,若是爲空則使用當前文檔的URL地址,若是表單中不須要使用action屬性也要指定其屬性爲「no」.post

enctype:設置表單的資料的編碼方式編碼

target:和超連接相似,用來指定目標窗口。orm

文本域和密碼:htm

<input></input>:<input name=」」  type=」 」 value=」 」 size=」 」maxlength=」 」></input>ip

Type:文檔

 type=」text」表示文本輸入域;

 type=」password」:密碼輸入域,會有星號隱藏密碼顯示;

 type=」submit」:提交按鈕;

 type=」reset」:重置按鈕;

 type=」button」爲普通按鈕。

 type=」redio」:單選框。Name相同的時候爲一組選項

 type=」checkbox」:複選框.

 type=」hidden」;隱藏域

Name:控件名稱,獲取控件名稱引用,document.getElementByName(「#name」) javascript的時候常常用到。
value:給控件賦值的時候使用或者默認值時候。

Size:設置控件長度。

Maxlength:輸入框中容許輸入最大字符數。

 注意:使用submit提交數據時,action沒有指定地址method沒有指定提交方式時,會自動默認get提交方式且獲取name的值默認傳遞當前地址。

多行文本域:<textarea name=」 」 value=」 」 cols=」 」 rows=」 」></textarea>

菜單下拉列表:

<select name=」xialakuang 」>

<option  >下拉選項1</option>

<option  >下拉選項2</option>

<option  >下拉選項3</option>

</select>

例子:

<form action="test.html" method="post">

    帳號:<input type="text" name="zhanghao"/><br>

    密碼:<input type="password" name="mima"/><br>

    <input type="submit" value="提交"/>

    <input type="reset" value="重置">

    <input type="button" value="普通按鈕"/>

    <input type="radio" value="女" name="性別" checked/>

    <input type="radio" value="男" name="性別"/>

    <input type="radio" value="無" name="性別"/>

    <input type="checkbox" value="芒果"/>

    <input type="checkbox" value="橘子" checked/>

    <input type="checkbox" value="香蕉"/>

    <input type="checkbox" value="柚子"/>

    這是一個隱藏域:<input type="hidden" />

   自我介紹: <textarea name="多行" value="" cols="22" rows="22">

    </textarea>

    <select name="hahaah" >

       <option  value="sichuan" >下拉選項1</option>

       <option  selected>下拉選項2</option>

       <option  >下拉選項3</option>

     </select>

    </form>
相關文章
相關標籤/搜索