1<html>
2<head>
3<title>动态下拉菜单</title>
4<style>
5SELECT.smallSel
6{
7BACKGROUND-COLOR: white;
8COLOR: #000080;
9FONT-SIZE: 9pt
10}
11</style>
12<script language="javascript">
13<!-- hide from old browsers...
14
15/* 动态下拉菜单 -- written by Taylor Chen (Taylor999)
16如果您发现任何问题,请E-mail给我,[email protected]
17*/
18
19
20var info = new Array(
21"杂文*弥天大谎的背后|院士相当于副省级?|为教育打几个激灵|预算黑洞一例|官不贵,民不贱|省了麻烦|
22
23轿车不如轿子说|这回确是个别|血和泪构成的笑话|给张艺谋松绑吧!",
24"生活随笔*木兰漂亮吗?|一张旧车票|酒味杂谈|时空隧道|最后捞一把",
25"文选*家庭也要有民主|“待遇”的联想|“农民”不是形容词|只多一点点",
26"读者*当代“士子”之悲|谈程序|厅长说与百姓说|其实很高明");
27
28var infoA=new Array(
29"焦点话题*安徽:国企领导可以超龄任职|新世纪怎么花钱|武汉:企业将告别行政级别",
30"读者书屋*欲火",
31"品味园*破译“中国人之谜”不妨读读《闲话中国人》|请客吃饭乐无穷|走动走动向上浮动|文人也当谋富
32
33|做并享受着———与白岩松笑谈摭拾|比谁写得厚",
34"环球采风*法国建成绿色学校|俄罗斯第一夫人温情谈恋史|法国人才外流有原因|德国电脑人才可破例|德
35
36国慕尼黑啤酒节",
37"人物春秋*我所知道的胡乔木|自信些,迎接全球化|红与黑");
38var mywork= new Array("",info,infoA);
39/************************************************************************************************
40
41******/
42
43function stringSplit ( string, delimiter ) {
44if ( string == null || string == "" ) {
45return null;
46} else if ( string.split != null ) {
47return string.split ( delimiter );
48} else {
49var ar = new Array();
50var i = 0;
51var start = 0;
52while( start >= 0 && start < string.length ) {
53var end = string.indexOf ( delimiter, start ) ;
54if( end >= 0 ) {
55ar[i++] = string.substring ( start, end );
56start = end+1;
57} else {
58ar[i++] = string.substring ( start, string.length );
59start = -1;
60}
61}
62return ar;
63}
64}
65/************************************************************************************************
66
67******/
68var menu1 = new Array();
69var menu2 = new Array();
70/************************************************************************************************
71
72******/
73function createMenus ( wh ) {
74var infoname = new Array();
75infoname=mywork[wh];
76for ( var i=0; i < infoname.length; i++ ) {
77menu1[i] = stringSplit ( infoname[i], '*' );
78menu2[i] = stringSplit ( menu1[i][1], '|' );
79}
80
81var author = document.myForm.main;
82var book = document.myForm.title;
83
84author.length = infoname.length;
85book.length = menu2[0].length;
86for ( var i=0; i < infoname.length; i++ ) {
87author.options[i].value = menu1[i][0];
88author.options[i].text = menu1[i][0];
89}
90document.myForm.main.selected = 0;
91for (var x=0; x < menu2[0].length; x++) {
92book.options[x].text = menu2[0][x];
93book.options[x].value = menu2[0][x];
94}
95document.myForm.title.selected = 0;
96}
97
98/************************************************************************************************
99
100******/
101
102function updateMenus ( what ) {
103var sel = what.selectedIndex;
104
105if ( sel >= 0 && sel < menu1.length )
106var temp = menu2[sel];
107else
108var temp = new Array ();
109
110what.form.title.length = temp.length;
111
112for ( var i = 0; i < temp.length; i++ ) {
113what.form.title.options[i].text = temp[i];
114what.form.title.options[i].value = temp[i];
115}
116what.form.title.selected=0;
117}
118// end of hiding -->
119</script>
120</head>
121<body alink="#ff0000" background="" bgcolor="#ffffff" link="#ff0080" text="#400040" vlink="#ff8080">
122<center><h1>动态下拉菜单</h1></center>
123<form action="test2.asp" method="post" name="myForm"><p>
124分类:
125<select class="smallsel" name="my" onchange="createMenus(document.myForm.my.selectedIndex)" size="1">
126<option selected=""></option>
127<option value="info">杂文报</option>
128<option value="infoA">书刊报</option>
129</select>
130<p>
131作者: <select class="smallsel" name="main" onchange="updateMenus(this)" size="1">
132<option>
133
134;
135<option>
136<option>
137</option></option></option></select>
138<p>
139标题:
140<select class="smallsel" name="title" size="1">
141<option>
142
143;
144<option>
145<option>
146</option></option></option></select>
147<input onclick="parent.location.href='http://www.hebeidaily.com.cn'" type="button" value="Submit"/>
148</p></p></p></form>
149</body>
150</html>
动态创建下拉菜单
comments powered by Disqus