级联菜单(DHTML)

级联菜单

<!DOCTYPE html>
<html>
<head>
<title>selcity.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
	function selCity() {
		var arr = [ [ '--选择城市--' ], [ "海淀", "朝阳", "东城", "西城" ],
				[ "沈阳", "大连", "鞍山", "抚顺" ], [ "济南", "青岛", "烟台", "威海" ],
				[ "洛阳", "郑州", "开封", "新郑" ] ];
		//拿到被选中的角标
		var index = document.getElementById("selid").selectedIndex;
		//alert(document.getElementById("selid").options[index].innerText);
		var subselNode = document.getElementById("subselid");
		var citys = arr[index];

		subselNode.options.length = 0;
		for ( var x = 0; x < citys.length; x++) {
			//alert(citys[x]);
			var optNode = document.createElement("option");
			optNode.innerText = citys[x];
			subselNode.appendChild(optNode);
		}

	}
</script>
</head>
<body>
	<select id="selid" οnchange="selCity()">
		<option>---选择省市---</option>
		<option>北京</option>
		<option>辽宁</option>
		<option>山东</option>
		<option>河南</option>
	</select>


	<select id="subselid">
		<option>---选择城市---</option>
	</select>
</body>
</html>
联动

<!DOCTYPE html>
<html>
<head>
<title>sel.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
#cssid {
	height: 100px;
	width: 300px;
	background-color: #FFCC00;
}

#textid {
	width: 300px;
	background-color: #CCCCCC;
}
</style>
<script type="text/javascript">
	function change() {

		var selNode = document.getElementById("selid");
		var value = selNode[selNode.selectedIndex].value;
		//alert(value);

		var divNode1 = document.getElementById("cssid");
		var divNode2 = document.getElementById("textid");

		divNode1.style.textTransform = value;
		divNode2.innerText = "text-transform: " + value + " ;"
	}
</script>
</head>

<body>
	<div id="cssid">good good study,Day day up!</div>
	<p></p>
	<select id="selid" οnchange="change()">
		<option value="none">---text---transform---</option>
		<option value="capitalize">首字母大写</option>
		<option value="uppercase">所有字母大写</option>
		<option value="lowercase">所有字母小写</option>
	</select>
	<p></p>
	<div id="textid">text-transform:none ;</div>
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值