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

HTML中的表单

2016-07-19 22:02 507 查看
HTML中的表单需要用到<form>标签,表单用于向服务器传输数据

<form action="后台文件.php" method="get">

表单内容

</form>

(method="get")表单数据可以作为 URL 变量

URL类似:

http://www.example.com/example/program?x=28&y=66

1.表单中的文本域

<textarea>标签

用法:

<textarea cols="20" rows="5">这里是文本域</textarea>

cols rows 为设置的文本域的宽高,单位像素

2.输入框

<input>标签

姓名<input type="text">
密码<input type="password">

3.单选框

<input type="radio" name="sex"/>男<br>
<input type="radio" name="sex"/>女<br>

---------男女只能选一个

<input type="radio" name="sex1" id="1"/><label for="1">男</label><br>
<input type="radio" name="sex2" id="2"/><label for="2">女</label><br>

---------两者都可以选择

4.复选框

<input type="checkbox" name="fuxuan">bike<br>
<input type="checkbox" name="fuxuan" checked="checked">car<br>

---------点击选择,再次点击取消选择

5.下拉菜单

<select multiple="multiple">
<option value="1">巧克力</option>
<option value="2">草莓</option>
<option value="3">香蕉</option>
<option value="4" selected="selected">野子</option>
</select>

multiple标签的意思为:可以多选,windows为ctrl  mac为comd

selected 默认选择为此项

6.定义域

<fieldset>
<legend>健康信息</legend>
身高<input type="text">
体重<input type="text">
</fieldset>

fieldset 元素可将表单内的相关元素分组。

legend用来定义标题

7.按钮

<input type="button" value="按钮"><br>
<input type="submit" value="提交"><br>
<input type="reset" value="重置"><br>

比较简单,功能和用法通俗易懂。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: