87,993
社区成员
发帖
与我相关
我的任务
分享
<style type="text/css">
<!--
div,
div div,
div div div {
margin-left: 15px;
display:block;
}
-->
</style>
<label><input name="china" type="checkbox" id="china" value="all" onclick="selectAllCity()">
全国</label><span class="kw"><a href="javascript:;" onclick="showAllCity()">(展开/隐藏所有城市)</a></span>
<div id="prolist_1">
<label><input name="pro[]" type="checkbox" id="pro_1" value="1">
</label>北京
<span class="kw"><a href="javascript:;" onClick="showCityList(1)">展开/隐藏</a></span>
<div id="citylist_1" style="display:none">
<label>
<input name="city[]" type="checkbox" id="city_1" value="1">
北京 </label><br>
</div><br>
<label><input name="pro[]" type="checkbox" id="pro_2" value="2">
</label>上海
<span class="kw"><a href="javascript:;" onClick="showCityList(2)">展开/隐藏</a></span>
<div id="citylist_2" style="display:none">
<label>
<input name="city[]" type="checkbox" id="city_2" value="2">
上海 </label><br>
</div><br>
<label><input name="pro[]" type="checkbox" id="pro_3" value="3">
</label>天津
<span class="kw"><a href="javascript:;" onClick="showCityList(3)">展开/隐藏</a></span>
<div id="citylist_3" style="display:none">
<label>
<input name="city[]" type="checkbox" id="city_3" value="3">
天津 </label><br>
</div><br>
<label><input name="pro[]" type="checkbox" id="pro_4" value="4">
</label>重庆
<span class="kw"><a href="javascript:;" onClick="showCityList(4)">展开/隐藏</a></span>
<div id="citylist_4" style="display:none">
<label>
<input name="city[]" type="checkbox" id="city_4" value="4">
重庆 </label><br>
</div><br>
<label><input name="pro[]" type="checkbox" id="pro_5" value="5">
</label>安徽
<span class="kw"><a href="javascript:;" onClick="showCityList(5)">展开/隐藏</a></span>
<div id="citylist_5" style="display:none">
<label>
<input name="city[]" type="checkbox" id="city_5" value="5">
合肥 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_6" value="6">
黄山 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_7" value="7">
芜湖 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_8" value="8">
马鞍山 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_9" value="9">
安庆 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_10" value="10">
淮南 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_11" value="11">
阜阳 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_12" value="12">
蚌埠 </label><br>
</div><br>
<label><input name="pro[]" type="checkbox" id="pro_6" value="6">
</label>福建
<span class="kw"><a href="javascript:;" onClick="showCityList(6)">展开/隐藏</a></span>
<div id="citylist_6" style="display:none">
<label>
<input name="city[]" type="checkbox" id="city_13" value="13">
福州 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_14" value="14">
厦门 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_15" value="15">
泉州 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_16" value="16">
漳州 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_17" value="17">
龙岩 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_18" value="18">
三明 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_19" value="19">
南平 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_20" value="20">
宁德 </label><br>
<label>
<input name="city[]" type="checkbox" id="city_21" value="21">
莆田 </label><br>
</div><br>
<script language="javascript" type="text/javascript">
//create date 2009-12-01 16:47:20
var cityArr=new Array();
cityArr[1]=[1];
cityArr[2]=[2];
cityArr[3]=[3];
cityArr[4]=[4];
cityArr[5]=[5,6,7,8,9,10,11,12];
cityArr[6]=[13,14,15,16,17,18,19,20,21];
function G(ID){
return document.getElementById(ID);
}
//全国
function selectAllCity(){
for(var pid in cityArr){
selectCity(pid);
}
}
//全国城市都显示隐藏
function showAllCity(){
for(var pid in cityArr){
showCityList(pid);
}
}
//选取城市列表
function selectCity(pid){
var pchecked=G("pro_"+pid).checked;
G("citylist_"+pid).style.display=(pchecked==true)?'':'none';
for(var c in cityArr[pid]){
G("city_"+cityArr[pid][c]).checked=(pchecked==true)?"checked":"";
}
}
//展现城市
function showCityList(pid){
var obj=G("citylist_"+pid).style;
obj.display=(obj.display)? '':'none';
return;
}
window.onload=function(){
var inputArr=document.getElementsByTagName("input");
for(var i=0;i< inputArr.length;i++){
if(inputArr[i].type!="checkbox"){continue;}//跳过
if(!(/^pro/.test(inputArr[i].id))){continue;}//跳过
inputArr[i].onclick=function(){
selectCity(this.value);//展现城市
}
}
}
</script>
function selectAllCity(){
for(var pid in cityArr){
G("pro_"+pid).checked = G("china").checked;
selectCity(pid);
}
}