1. 程式人生 > >HTML表單設計(下)

HTML表單設計(下)

語法 設置 password bsp multi 服務器 唱歌 tip method

4,單選框和復選框

  a,當<input type=“radio”>時,為單選按鈕

  b,當<input type=“chekebox”>時,為復選框

  c,註意:單選框和復選框都可以使用“cheked”屬性來設置默認選中項

5,隱藏域

  當<input type=“hidden”>時,為隱藏表單域

6,多行文本域

  用法,使用<textarea>標記可以實現一個,能夠輸入多行文本的區域

  語法格式<textarea name=“name” rows =“value” value=“value”>......</textarea>

  rows屬性和cols屬性分別用來指定,顯示的行數和列數,單位是字符個數

7,菜單下拉列表域

  select標記

  語法格式:

    a,<select name=“” size=“” multiple>

    b,<option value=“value” selected>選項1</option>

    c,.....</select>

  屬性

  option標記

    <option>標記用來指定列表中的一個選項,需要放在<option><option>之間

    給選項賦值,指定傳送到服務器上面的值

    selected 指定默認的選項

eg:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表單設計</title>
</head>
<body>
<form action="no" method="get">
帳號:<input type="text" name="name" value="" size="10" maxlength="5">
<br><br>
密碼:<input type="password" name="password" value="" size="10" src="5">
<br><br>
<input type="hidden" value="隱藏的內容" size="10" name="dsjfldsfjsd">
愛好:<input type="checkbox" name="tiyu" checked>體育<input type="checkbox" name="changge">唱歌
<br><br>
性別:<input type="radio" name="sex" checked>男<input type="radio" name="sex">女
<br><br>
自我介紹:
<textarea cols="55" rows="10" name="ziwojieshao">
這裏是自我介紹

</textarea>
<br><br>
地址:
<select>
<option value="sichuan">四川</option>
<option value="beijing">北京</option>
<option value="shanghai">上海</option>
</select>
<br><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
<input type="button" value="按鈕">
</form>
</body>
</html>

HTML表單設計(下)