表单元素格式
属性 | 说明 |
type | 指定元素的类型,文本框text,密码框password,多选框checkbox,单选框radio,提交按钮submit,重置按钮reset,文件框file,隐藏hidden,图片框image,按钮button |
name | 指定表单元素的名称 |
value | 元素的初始值,type为单选框radio时必须指定一个值 |
size | 指定表单元素的初始宽度,当type为text或者password时,表单元素的大小以字符为单位,对其他的类型,宽度以像素为单位 |
maxlength | type为text或password时,输入的最大字符数 |
checked | type为radio或者checkbox时,指定按钮是否被选中 |
单选框
上为显示效果,下为代码
<form method="get" action="result.html">
<p>用户名:<input type="text" name="username" value="文本框初始值"
maxlength="8" size="30"/></p>
<p>密码:<input type="password" name="pwd"/></p>
<p>性别:
<input type="radio" value="boy" name="sex"/>男
<input type="radio" value="girl" name="sex"/>女
</p>
<p><input type="submit"/>
<input type="reset"/></p>
</form>