Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
單的作用:用來收集用戶的信息。
提示信息: 說明性的文字,用于提示用戶進(jìn)行填寫和操作。
表單控件:包含了具體的表單功能項,如文本框、密碼框、單選框、復(fù)選框、提交按鈕、重置按鈕等。
表單域:相當(dāng)于一個容器,用來容納所有的表單控件和提示信息,可以通過它定義處理表單數(shù)據(jù)提交的url地址,以及數(shù)據(jù)提交到服務(wù)器的方法。如果不定義表單域,表單中的數(shù)據(jù)就無法傳送到后臺服務(wù)器。
<input />標(biāo)簽為單標(biāo)簽,type屬性為input標(biāo)簽最基本的屬性,取值有多種,用于指定不同的標(biāo)簽類型。除了type屬性之外,<input />標(biāo)簽還可以定義很多其他的屬性:
文本框 <input type="text" value="默認(rèn)值"/>
密碼框 <input type="password" />
單選按鈕組
<input type=“radio” name=“ral” />男
<input type=“radio” name=“ral” checked=“checked”/>(默認(rèn)選中)女
<!--*disabled="disabled" (禁用) * checked="checked" (默認(rèn)選中)-->
復(fù)選框組
<input type="checkbox" name="" />
<input type="checkbox" name="" disabled="disabled" />
按鈕組:
空按鈕 <input type="button" value="按鈕內(nèi)容" />
提交按鈕 <input type="submit" value="按鈕內(nèi)容" />
重置按鈕 <input type="reset" value="按鈕內(nèi)容" />
圖片按鈕 <input type="image" src='bg.png' />
文件按鈕 <input type="file" />
label 標(biāo)簽為 input 元素定義標(biāo)注。
<label>
<input type="text" value="">
</label>
<label for="name">姓名</label>
<input type="text" id="name" value="">
如果需要輸入大量的信息,則需要用到<textarea></textarea>標(biāo)簽。textarea控件可以創(chuàng)建多行文本輸入框,語法:
<textarea cols="每行中顯示的字符數(shù)" rows="顯示的行數(shù)">
文本信息
</textarea>
<select>
<option>選項1</option>
<option selected>選項2</option>
<option>選項3</option>
...
</select>
關(guān)于表單的第一節(jié)課,我們講過表單由三部分組成:表單控件(input控件,select、textarea、button)、提示信息、表單域。
在HTML中,form標(biāo)簽用于定義表單域,即創(chuàng)建一個表單,用來收集和傳遞用戶的輸入信息,指定提交到的服務(wù)器,以及提交方式。
例
創(chuàng)建帶有 4 個選項的選擇列表:
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
瀏覽器支持
大多數(shù)主流瀏覽器支持 <option> 標(biāo)簽。
標(biāo)簽定義及使用說明
The <option> 標(biāo)簽定義下拉列表中的一個選項(一個條目)。
<option> 標(biāo)簽中的內(nèi)容作為 <select> 或者<datalist> 一個元素使用。
提示和注釋
注釋:<option> 標(biāo)簽可以在不帶有任何屬性的情況下使用,但是您通常需要使用 value 屬性,此屬性會指示出被送往服務(wù)器的內(nèi)容。
注釋:請與 select 元素配合使用此標(biāo)簽,否則這個標(biāo)簽是沒有意義的。
提示:如果列表選項很多,可以使用 <optgroup> 標(biāo)簽對相關(guān)選項進(jìn)行組合。
屬性
屬性 | 值 | 描述 |
---|---|---|
disabled | disabled | 規(guī)定此選項應(yīng)在首次加載時被禁用。 |
label | text | 定義當(dāng)使用 <optgroup> 時所使用的標(biāo)注。 |
selected | selected | 規(guī)定選項(在首次顯示在列表中時)表現(xiàn)為選中狀態(tài)。 |
value | text | 定義送往服務(wù)器的選項值。 |
全局屬性
<option> 標(biāo)簽支持全局屬性,查看完整屬性表 HTML全局屬性。
事件屬性
<option> 標(biāo)簽支持所有 HTML事件屬性。
如您還有不明白的可以在下面與我留言或是與我探討QQ群308855039,我們一起飛!
單標(biāo)簽
常見的語句:
form:表單標(biāo)簽格式
作用:用來收集用戶輸入信息如:登入、注冊、搜索商品等
action:開始網(wǎng)址
method:get和post等等
text (明文):用戶名格式
password :(密文)密碼
radio :單選框 性別格式 性別是單選,單選類型是radio,注意name要加上sex
checkbox:復(fù)選框
textarea:文本框
file:上傳文件
select:下拉選擇框
button:按鈕
reset:重置
submit:提交
詳解:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>表單標(biāo)簽</title>
</head>
<body>
<form action="https://hao.360.com/" method="post">
<p>賬號:<input type="text" /></p>
<p>密碼:<input type="password" /></p>
<p>
<input type="radio" name="sex" id="" />男
<input type="radio" name="sex" id="" />女
</p>
<p>
<input type="checkbox" name="" id="" value="" />linux
<input type="checkbox" name="" id="" value="" />mysql
<input type="checkbox" name="" id="" value="" />html
<input type="checkbox" name="" id="" value="" />python
</p>
<p>學(xué)歷
<select name="">
<option value="">請選擇學(xué)歷</option>
<option value="">小學(xué)</option>
<option value="">初中</option>
<option value="">高中</option>
<option value="">大學(xué)</option>
</select>
</p>
<p>自我介紹:<br />
<textarea name="" rows="10" cols="30"></textarea>
</p>
<input type="reset" value="重置"/>
<input type="submit" value="提交"/>
<input type="button" value="按鈕"/>
</form>
</body>
</html>
*請認(rèn)真填寫需求信息,我們會在24小時內(nèi)與您取得聯(lián)系。