表單的作用
HTML 表單用于接收不同類型的用戶輸入,用戶提交表單時(shí)向服務(wù)器傳輸數(shù)據(jù),從而實(shí)現(xiàn)用戶與Web服務(wù)器的交互
表單的工作機(jī)制
用戶在表單框里輸入內(nèi)容,提交數(shù)據(jù)并發(fā)送給服務(wù)器,服務(wù)器接收并處理
表單定義的格式
<form action=“reg.php" method="post">
<!--表單元素在這里-->
</form>
表單屬性
action是寫入url數(shù)據(jù)提交到后臺(tái)的地址
method有post和get兩種請(qǐng)求方式,區(qū)別在于get請(qǐng)求時(shí)是向后臺(tái)請(qǐng)求數(shù)據(jù),post常用來(lái)向后臺(tái)上傳數(shù)據(jù),post方式可傳輸?shù)臄?shù)據(jù)量更大而且安全性也比get好
常用標(biāo)簽有
普通文本框<input type="text" name="" value="" placeholder /> placeholder是提示文本內(nèi)容
密碼框 <input type="password" name="pwd" />
單選框 <input type="radio" name="" value="" />
復(fù)選框 <input type="checkbox" name="" value="" />
重置按鈕 <input type="reset" value="" />
上傳文件 <input type="file" name="" />
下拉列表
<select name=""> <option value="1"></option> <option value="2"></option> </select>
文本域 <textarea></textarea>
隱藏項(xiàng) <input type="hidden" name="trueName" value="" />
圖片提交按鈕 <input type="image" src="" />
提交按鈕 <input type="submit" name="提交" />
普通按鈕 <input type="button" name="提交" value="提交" />