表单
表单是用户与网站数据交换的工具
表单标签及属性
1.form :action、 method
2.input :type
3.button
Demo
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>form</title>
</head>
<body>
<h3>用户注册</h3>
<form action=" " method="post" >
<p>
<label for="user">账号:</label>
<input type="text" name="username" id="user" />
</p>
<p>
<label for="pwd">密码:</label>
<input type="password" name="password" id="pwd" />
</p>
<p><button>提交</button></p>
</form>
</body>
</html>
4.select(name)+option(value)
Demo
<p>
<select name="level" id="">
<option value="1">第一名</option>
<option value="2">第二名</option>
<option value="3" selected>第三名</option> <!--selected,默认选中-->
<option value="4">第四名</option>
</select>
</p>
5.radio 单选按钮
Demo
<p>
<label for="female">性别:</label> <!--通过for绑定female,当点击“性别”两个字时,选中“女”按钮-->
<input type="radio" name="gender" id="male" checked><label for="male">男</label> <!--checked,默认选中-->
<input type="radio" name="gender" id="female"><label for="female">女</label>
</p>
6.checkbox 复选框
Demo
<!--复选框里的名称(name)属性用数组标注-->
<p>
<input type="checkbox" name="hobby[]" id="shoot"/><label for="shoot">摄影</label>
<input type="checkbox" name="hobby[]" id="travle" checked/><label for="movie">看电影</label><!--checked,默认选中-->
<input type="checkbox" name="hobby[]" id="running"/><label for="running">健身</label>
</p>
7.hidden 隐藏域
Demo
<p>
<input type="hidden" name="user_id" value="101" />
</p>
完整案例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>form</title>
</head>
<body>
<h3>用户注册</h3>
<form action=" " method="post" >
<p>
<label for="user">账号:</label>
<input type="text" name="username" id="user" />
</p>
<p>
<label for="pwd">密码:</label>
<input type="password" name="password" id="pwd" />
</p>
<!--列表菜单-->
<p>
<select name="level" id="">
<option value="1">第一名</option>
<option value="2">第二名</option>
<option value="3" selected>第三名</option><!--selected,默认选中-->
<option value="4">第四名</option>
</select>
</p>
<!--隐藏域-->
<p>
<input type="hidden" name="user_id" value="101" />
</p>
<!--单选按钮-->
<p>
<label for="female">性别:</label> <!--通过for绑定female,当点击“性别”两个字时,选中“女”按钮-->
<input type="radio" name="gender" id="male" checked><label for="male">男</label> <!--checked,默认选中-->
<input type="radio" name="gender" id="female"><label for="female">女</label>
</p>
<!--复选框-->
<!--复选框里的名称(name)属性用数组标注-->
<p>
<input type="checkbox" name="hobby[]" id="shoot"/><label for="shoot">摄影</label>
<input type="checkbox" name="hobby[]" id="travle" checked/><label for="movie">看电影</label><!--checked,默认选中-->
<input type="checkbox" name="hobby[]" id="running"/><label for="running">健身</label>
</p>
<!--按钮-->
<p><button>提交</button></p>
</form>
</body>
</html>