一、基礎概念知識
1.表單主要分為兩部分:
一是HTML文檔描述的表彰;
二是提交后的表單處理(服務器端處理數(shù)據(jù),這里只介紹客戶端)
2.表單的格式如下:
<form name="" method="" action="" enctype="">
表單項,文字,圖片等
</form>
描述:name表示表單的名稱;action用來指定接收表彰數(shù)據(jù)的服務器頁面(JSP,PHP)等等;methos是指定表彰的傳輸方式,post或get;enctype指定傳遞數(shù)據(jù)的編碼方式。
3.表單有以下幾個常用表單項,可以用來輸入數(shù)據(jù):
<input type="text">單行文本框
<input type="password"> 密碼
<input type="submit">提交表單按鈕
<input type="image"> 圖片提交
<input type="reset">重置按鈕
<input type="button">普通按鈕
<input type="hidden">隱藏元素
<input type="radio">單選按鈕
<input type="checkbox">復選框
<input type="file">文件域
<select>...</select>列表框
<textarea>...</textarea>多行文本框
二、各個表單項的簡單介紹
1.單行文本框的格式:
<input type=text name="名稱" size="數(shù)值" value="預設內(nèi)容" maxlength="數(shù)值">
2.密碼框格式:
<input type=password name="名稱" size="數(shù)值" value="預設內(nèi)容" maxlength="數(shù)值">
3.提交按鈕:
<input type=submit name="名稱" value="預設內(nèi)容"
4.圖片提交:
<input type=image src="圖片路徑" name="名稱" alt="替代文本" width="寬度" height="高度">
其中alt是指在光標經(jīng)過圖像或者圖像不顯示時的替換文本
5.重置按鈕格式:
<input type="reset" name="名稱" value="預設內(nèi)容">
6.普通按鈕格式:
<input type="button" name="名稱" value="預設內(nèi)容">
其可以和Javascript一塊使用,如:
<input type="button" name="button1" value="單擊進入" onclick="alert('單擊按鈕')">
7.隱藏元素按鈕:
<input type="hidden" name="參數(shù)" value="參數(shù)取值">
功能:多用于向服務器傳遞一些不需要用戶所知道的一些信息,如IP地址。
8.單選按鈕格式:
<input type="radio" name="名稱" value="預設內(nèi)容" checked="checked">
9.復選框格式:
<input type="checkbox" name="名稱" value="預設內(nèi)容" checked="checked">
10.下拉列表格式:
<select name="名稱" size="大小" multiple="multiple">
<option value=""></option>
<option value=""></option>
</select>
11.多行文本框格式:
<textarea name="名稱" rows="行數(shù)" cols="列數(shù)"></textarea>