1.4 表单
form标签
表单标签,每一对代表一个表单
method 必填项,提交方式,默认post即可
action 提交地址
target 打开方式,与 a 标签的target属性一样,一般默认_blank即可
enctype 编码方式,一般情况不需要进行设置
<form method="post">
</form>
input标签
在表单中用到最多的标签,大多的表单都由他实现
<input type="表单属性"/>
单行文本框 text
value 默认值
size 文本框长度
maxlength 文本框的字符数
<from method="post">
姓名:<input type="text" />
</from>
密码文本框 password
在密码文本框中输入的字符会被加密处理,显示出的字符为星号“*”。
value 默认值
size 文本框长度
maxlength 文本框的字符数
<from method="post">
密码:<input type="password" />
</from>
单选框 radio
name 必填项组名,用于是单选框的原因,即在同一组内只能选择一个选项
value 必填项取值,即选中此选项后上传时发送的信息
checked 默认值
<from method="post">
性别<input type="radio" name="xingbie" value="男" checked/>男
<input type="radio" name="xingbie" value="女" />女
</from>
复选框 checkox
name 必填项组名
value 必填项取值
checked 默认值
<from method="post">
你喜欢些什么:
<input type="checkox" name="aihao" value="写作" />写作
<input type="checkox" name="aihao" value="音乐" />音乐
<input type="checkox" name="aihao" value="运动" />运动
<input type="checkox" name="aihao" value="赚钱" />赚钱
<input type="checkox" name="aihao" value="学习" />学习
</from>
按钮
普通按钮 button
<from method="post">
密码:<input type="button" value="按钮上的字"/>
</from>
提交按钮 submit
提交到from所设定的地址中
<from method="post">
密码:<input type="submit" value="按钮上的字"/>
</from>
重置按钮 reset
清除用户在此表单中所有的操作
<from method="post">
密码:<input type="reset" value="按钮上的字"/>
</from>
文件上传 file
<from method="post">
密码:<input type="file" />
</from>
多行文本框 textarea
<textarea rows="行数" cols="列数" value="">默认内容</textarea>
使用方法:
简历:<textarea rows="5" cols="20">请介绍自己</textarea>
下拉列表
<from method="post">
<select>
<option>选取内容</option>
……
<option>选取内容</option>
</select>
</from>
<from method="post">
性别:
<select>
<option>男</option>
<option>女</option>
</select>
</from>
select属性
multiple
设置下拉列表多选
size
设置下拉列表的高度
<from method="post">
<select multiple size="5">
<option>选取内容</option>
……
<option>选取内容</option>
</select>
</from>

浙公网安备 33010602011771号