-
Notifications
You must be signed in to change notification settings - Fork 0
/
31.html
78 lines (75 loc) · 2.95 KB
/
31.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>
<input type="radio" checked="checked" id="stu" name="type">
<label for="stu">在校生</label>
<input type="radio" id="social" name="type">
<label for="social">社会人</label>
</div>
<div>
<div id="stu_group">
<label for="city">学校</label>
<select name="city" id="city">
<option value="hunan">湖南</option>
<option value="beijing">北京</option>
</select>
<div id="schoolList" style="display:inline-block;">
<select name="school" id="hunan">
<option value="xx">湖南人文科技学院</option>
<option value="xx">湖南人文科技学院</option>
</select>
<select name="school" id="beijing" style="display: none;">
<option value="xx">北京大学</option>
<option value="xx">清华大学</option>
</select>
</div>
</div>
<div id="social_group" style="display:none;">
<label for="work">就业单位</label>
<select name="work" id="work">
<option value="baidu">百度</option>
<option value="baidu">百度</option>
</select>
</div>
</div>
<script type="text/javascript">
var social = document.getElementById("social");
var student = document.getElementById("stu");
var school = document.getElementById("schoolList");
social.addEventListener("change",studentCheck,false);
student.addEventListener("change",studentCheck,false);
document.getElementById("city").addEventListener("change",schoolShow,false);
//radio的change事件只有被点击那个才会触发
function schoolShow (){
var index = this.selectedIndex;//选中Select的索引,下标
var city_name = this.options[index].value;
var child = school.children;
for(var i = 0;i<child.length;i++)
{
if(child[i].id==city_name)
child[i].style.display="block";
else
child[i].style.display="none";
}
}
function studentCheck(){
var newName = this.getAttribute("id");
if(newName=="stu")
{
document.getElementById("stu_group").style.display = "block";
document.getElementById("social_group").style.display="none";
}
else{
document.getElementById("stu_group").style.display = "none";
document.getElementById("social_group").style.display="block";
}
}
</script>
</body>
</html>