1,表單標記<form>...</form>
<form>...</form>定義表單的開始位置和結束位置,表單提交時的內容就是<form>表單的內容
基本格式<form action =“服務器端地址(接受表單內容的地址)” name =“表單名稱” method=“post/get”>...</form>
常用屬性
a,name表單名稱
b,method傳遞數據的方式,分為post和get兩種方式
get方式:get方式提交時,會講表單的內容附加在URL地址的后面,所以限制了提交的內容的長度,不超過8192字符,且不具備保密性
post方式:post方式提交時,將表中的數據的數據一並包含在表單主體中,一起傳送到服務器中處理,沒有數據大小限制
c,action表單數據的處理程序的URL地址,如果為空則使用當前文檔的URL地址,如果表單中不需要使用action屬性也要指定其屬性為 “no”
d,enctype設置表單的資料的編碼方式
e,target和超連接的屬性類似,用來指定目標窗口
2,文本域和密碼<input>標記
<input>標記沒有結束標記
基本語法<input type=“” name=“” value=“” size=“” maxlength=“”>
屬性介紹
a,type屬性 有兩個值 1,text 當type=“text”時,<input>表示一個文本輸入域 2,password 當type=“password”時,<input>表示一個密碼輸入域
b,name屬性 定義控件的名稱
c,value屬性 初始化值,打開瀏覽器時,文本框中的內容
d,size屬性 設置控件的長度
e,maxlength屬性 輸入框中最大允許輸入的字符數
3,提交,重置和普通按鈕
a,當<input type=“submit”>時,為提交按鈕
b,當<input type=“reset”>時,為重置按鈕
c,當<input type=“botton”>時,為普通按鈕
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="5" maxlength="5">
<br><br>
密碼:<input type="password" name="password" value="" src="5">
<br><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
<input type="button" value="按鈕">
</form>
</body>
</html>
