基本概念知識
表單主要分為兩部分
一是html文檔描述的表彰
二是提交后的表單處理(服務器端處理數據,這里只介紹客戶端)
表單的格式如下:
<form name="" method="" action="" enctype="">
表單項,文字,圖片等
</form>
描述:name表示表單的名稱;action用來指定接收表彰數據的服務器頁面(JSP,PHP)等等;methos是指定表彰的傳輸方式,post或get;enctype指定傳遞數據的編碼方式。
表單有以下幾個常用表單項,可以用來輸入數據:
<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>多行文本框
各個表單項的簡單介紹
單行文本框的格式:
<input type=text name="名稱" size="數值" value="預設內容" maxlength="數值">
密碼框格式:
<input type=password name="名稱" size="數值" value="預設內容" maxlength="數值">
提交按鈕:
<input type=submit name="名稱" value="預設內容"
普通按鈕格式:
<input type="button" name="名稱" value="預設內容">
其可以和Javascript一塊使用,如:
<input type="button" name="button1" value="單擊進入" onclick="alert('單擊按鈕')">
隱藏元素按鈕:
<input type="hidden" name="參數" value="參數取值">
功能:多用于向服務器傳遞一些不需要用戶所知道的一些信息,如IP地址
單選按鈕格式:
<input type="radio" name="名稱" value="預設內容" checked="checked">
復選框格式:
<input type="checkbox" name="名稱" value="預設內容" checked="checked">
下拉列表格式:
<select name="名稱" size="大小" multiple="multiple">
<option value=""></option>
<option value=""></option>
</select>