您的位置:首页 > Web前端 > HTML

html基础之表单

2016-01-06 14:41 567 查看
8.1表单的用途和属性<br/>
数据传递方式:post和get。<br/>
enctype属性用于指定表单数据编码类型。其值有以下几种<br/>
application/x-www-form-urlencoded:窗体数据被编码为名称/值对,这是标准的编码格式。
multipart/form-data:窗体数据被编码为一条消息,页面上的每个控件对应消息中的一个部分。
text/plain:窗体数据以纯文本形式进行编码,其中不含任何控件和格式字符。

8.2表单的控件<br/>
8.2.1单行文本控件框控件和密码框控件<br/>
<form name="wenben" method="post" action="#.php">
<input type="text" name="txt1" size="20" maxlength="10" value="请填写文本内容" /><br/>
<input type="text" name="txt2" size="25" maxlength="15" value="文本内容不能被更改" readonly="true" /><br/>
密码:<input type="password" name="pwd" size="10" maxlength="6" /><br/>
</form>
8.2.2多行文本框控件<br/>
cols和rows用来设置宽度和行数;wrap属性用来设置换行方式,常用的值为off(不自动换行)、virtual(自动换行换行处没有换行符号)、physical(自动换行处没有换行符号)<br/>
<form name="wenben" method="post" action="#.php">
<textarea name="#" cols="45" rows="4" wrap="off" >修改内容,关闭自动换行</textarea><br/>
<textarea name="#" cols="45" rows="4" wrap="physical" >修改内容,开启自动换行</textarea><br/>
<textarea name="#" cols="45" rows="4" readonly="true" >无法修改内容</textarea><br/>
</form>

8.2.3不同类型的按钮控件<br/>
按钮分为submit、reset、button三种type。<br/>
<form name="wenben" method="post" action="#.php">
<input type="submit" name="#" value="提交按钮" />
<input type="reset" name="#" value="复位按钮" />
<input type="button" name="#" value="普通按钮" />
</form>
8.2.4单选框控件和复选框控件<br/>
单选框和复选框checked属性以确定初始值。表单还提供了babel双标签,包含在内的文字可以选定控件。
<form name="select" method="post" action="#.php">
单选框(带有label标签):<br/>
<label><input type="radio" name="radio"
4000
checked="checked" />选项1</label>
<label><input type="radio" name="radio" />选项2</label>
<label><input type="radio" name="radio" />选项3</label>
<hr/>
复选框<br/>
<input type="checkbox" name="chk" checked="checked" />选项1
<input type="checkbox" name="chk" />选项2
<input type="checkbox" name="chk" />选项3<hr/>
<input type="reset" value="reset"/>
</form>

8.2.5下拉列表和列表框控件<br/>
select标签如果加上multiple属性,下拉列表即呈现为列表框控件,其size属性设置所显示数据项的数量。<br/>
<form name="sel" method="post" action="#.php">
<select name="select">
<option value="html" select="selected">html</option>
<option value="css">css</option>
<option value="jsp">jsp</option>
</select><hr/>
<select name="select1" size="3" multiple="multiple">
<option>html</option>
<option select="selected">css</option>
<option>jsp</option>
</select>
</form>

8.2.6图像域控件、文本域控件和隐藏域控件<br/>
<form name="form1" method="post" action="#.php">
图像域(单击图片类似于单价提交按钮)<br/>
<input type="image" src="bbh.jpg" width="200" /><hr/>
文件域<br/>
<input type="file" /><hr/>
隐藏域<br/>
<input type="hidden" name="txt" value="我是隐藏域中的值" /><hr/>
</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  html 表单 控件