入门HTML之复选框 单选框 下拉列表

复选框(Checkbox) 
在一个表单里的所有多选框可以有一个或多个被选中。
<input type=checkbox>
<input type=checkbox checked>

<input type=checkbox value=**>

<html>
<head>
	<title>复选框</title>
</head>
<body>
	请选择您喜欢的音乐:<br>
	<form>
	<input type = "checkbox">摇滚<br><br>
	<input type = "checkbox">爵士<br><br>
	<input type = "checkbox">流行<br><br>
	</form>
</body>
</html>
	

单选框(RadioButton)
一个表单里的所有变量名相同的单选框只能够有一个被选中。
<input type=radio  name=sex value=**>
<input type=radio name=sex value=** checked>
各个选项的name必须一样才能达到预期效果

<html>
<head>
	<title>单选框</title>
</head>
<body>
	请选择您喜欢的音乐(只能选一种)
	<form>
	<input type = radio name = sex>摇滚<p>
	<input type = radio name = sex>爵士<p>
	<input type = radio name = sex>流行<P>
	</form>
</body>
</html>
7.下拉列表
基本语法
<select name=*> <option selected>说明</option>
<option value=**>说明2 </option>
</select>

<html>
<head>
	<title>列表框选择</title>
</head>
<body>
	<select name = music>
	<option value = 1>摇滚
	<option value = 2 selected>爵士
	<option value = 3>流行	
	</select>
<p>
	<input type = submit value = "提交">
	<input type = "reset" value = "重设">
</body>
</head>
</html>
7.下拉列表
(2)列表框的长度
<select size=**>
(3)允许多选
<select size=** multiple>

<html>
<head>
	<title>列表框的长度</title>
</head>
<body>
	<select size = 8 name = music>
	<option value = 1>爵士
	<option value = 2>流行
	<option value = 3 selected>摇滚
	<option value = 4>民乐
	<option value = 5>儿歌
	</select>
</body>
</html>

<html>
<head>
	<title>列表框多选</title>
</head>
<body>
	<select size = 8 name = music multiple>
	<option>流行
	<option>摇滚
	<option>爵士
	<option>民乐
	</select>
<p>
	<input type = "submit" name = submit value = "提交">
</body>
</html>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值