求助!下拉框内容的改变!

我的xml和xsl文件如下:
xl.xml:

1<cd>   
2&lt;变更&gt;   
3&lt;人数/&gt;   
4&lt;类型/&gt;   
5&lt;类型细分/&gt;   
6<!--变更-->
7</cd>

xl.xsl:

 1<xsl:stylesheet result-ns="" xmlns="http://www.w3.org/TR/REC-html40" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
 2<xsl:template>
 3<xsl:apply-templates></xsl:apply-templates>
 4</xsl:template>
 5<xsl:template match="/">
 6<html>
 7<head>
 8<title>变更</title>
 9</head>
10<body onload="load()">
11<xsl:apply-templates select="CD/变更"></xsl:apply-templates>
12</body>
13</html>
14</xsl:template>
15<xsl:template match="变更">
16<form action="" method="post" name="form1">
17<p></p>
18<table align="center" border="0" cellspacing="0" width="974">
19<tr>
20<td height="550">
21<table align="center" border="0" cellspacing="0" width="100%"></table>
22<td height="546"></td>
23<table align="center" border="0" cellpadding="0" cellspacing="0" height="264" width="72%">
24<tr>
25<td height="35"><table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
26<tr>
27<td width="17%"><font face="宋体" size="2">人数</font></td>
28<td width="30%"><font face="宋体" size="2"></font><input name="人数" type="text"/></td>
29<td width="7%"></td>
30<td width="17%"><font face="宋体" size="2">类型</font></td>
31<td width="29%"><select name="类型" size="1">
32<option value="0">干部</option>
33<option value="1">群众</option>
34</select></td>
35</tr>
36</table></td>
37</tr>
38<tr>
39<td height="35"><table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
40<tr>
41<td width="17%"><font face="宋体" size="2">类型细分</font></td>
42<td width="30%">
43<select name="类型细分" size="1">
44<option value="ld1">科长</option>
45<option value="ld2">处长</option>
46<option value="ld3">局长</option>
47<option value="qz">群众</option>
48</select></td>
49<td width="7%"></td>
50<td width="17%"></td>
51<td width="29%"></td>
52</tr>
53</table></td>
54</tr>
55</table></td>
56</tr>
57</table>
58</form>
59</xsl:template>
60</xsl:stylesheet>

要实现的功能是,当类型下拉框选择干部时,类型细分下拉框中的选项只有科长、处长、局长,而当类型下拉框选择群众时,类型细分下拉框中的选项只有群众;
要实现这样的功能,该怎么做?请各位高手指教,多谢!
---------------------------------------------------------------

 1<xsl:stylesheet result-ns="" xmlns="http://www.w3.org/TR/REC-html40" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
 2<xsl:template>
 3<xsl:apply-templates></xsl:apply-templates>
 4</xsl:template>
 5<xsl:template match="/">
 6<html>
 7<head>
 8<title>变更</title>
 9<script language="javascript" type="text/javascript">   
10<xsl:comment>   
11<![CDATA[   
12var arr=new Array;   
13var opts=null;   
14var opts2=null;   
15arr[0]=[['科长','ld1'],['处长','ld2'],['局长','ld3']];   
16arr[1]=[['群众','qz']];   
17  
18function addOption(key){   
19if(key>arr.length) key=0;   
20var arrLen=arr[key].length;   
21for(var i=0;i<arrLen;i++){   
22var o=new Option(arr[key][i][0],arr[key][i][1],true,false);   
23opts2.options[opts2.options.length]=o;   
24}   
25}   
26  
27function delOption(){   
28while(opts2.length>0)   
29opts2.remove(0);   
30}   
31  
32function toChange(){   
33var key=0;   
34key=opts[opts.selectedIndex].value;   
35delOption();   
36addOption(key);   
37}   
38  
39function init(){   
40opts=document.all.type;   
41opts2=document.all.type2;   
42opts.onchange=toChange;   
43addOption(0);   
44}   
45]]>   
46  
47</xsl:comment>   
48</script>
49</head>
50<body onload=" init()">
51<xsl:apply-templates select="CD/变更"></xsl:apply-templates>
52</body>
53</html>
54</xsl:template>
55<xsl:template match="变更">
56<form action="" method="post" name="form1">
57<p></p>
58<table align="center" border="0" cellspacing="0" width="974">
59<tr>
60<td height="550">
61<table align="center" border="0" cellspacing="0" width="100%"></table>
62<td height="546"></td>
63<table align="center" border="0" cellpadding="0" cellspacing="0" height="264" width="72%">
64<tr>
65<td height="35"><table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
66<tr>
67<td width="17%"><font face="宋体" size="2">人数</font></td>
68<td width="30%"><font face="宋体" size="2"></font><input name="人数" type="text"/></td>
69<td width="7%"></td>
70<td width="17%"><font face="宋体" size="2">类型</font></td>
71<td width="29%">
72<select name="type" size="1">
73<option value="0">干部</option>
74<option value="1">群众</option>
75</select></td>
76</tr>
77</table></td>
78</tr>
79<tr>
80<td height="35"><table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
81<tr>
82<td width="17%"><font face="宋体" size="2">类型细分</font></td>
83<td width="30%">
84<select name="type2" size="1"></select></td>
85<td width="7%"></td>
86<td width="17%"></td>
87<td width="29%"></td>
88</tr>
89</table></td>
90</tr>
91</table></td>
92</tr>
93</table>
94</form>
95</xsl:template>
96</xsl:stylesheet>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus