登陆 | 免费注册(只需一分钟) | 会员中心

聚宝网   购物专题 基金专题 性专题 饮食专题 教育专题 生活大参考 园林资讯 园艺库 健康专题
  论文专题 家庭养花 园林景观 盆景奇石 激情图库 农业资料库 园林古建 英文站 花卉栽培

聚宝网免费为您提供 最新IT资讯

 

首页 > 网页设计 > Xml
求助!下拉框内容的改变!
时间:2007-06-17  www.jubao163.com  来源: 不详

我的xml和xsl文件如下:
xl.xml:
<?xml version="1.0" encoding="GB2312" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="xl.xsl"?>
<CD>
<变更>
<人数/>
<类型/>
<类型细分/>
</变更>
</CD>

xl.xsl:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40" result-ns="">
    <xsl:template>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>变更</TITLE>
</HEAD>
<BODY onload="load()">
<xsl:apply-templates select="CD/变更"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="变更">
<form name="form1" method="post" action="">
<p></p>
<table width="974" border="0" align="center" cellspacing="0">
  <tr> 
    <td height="550">
     <table width="100%" border="0" align="center" cellspacing="0"/>
<td height="546"/>
      <table width="72%" height="264" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr> 
            <td height="35"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="17%"><font size="2" face="宋体">人数</font></td>
                  <td width="30%"><font size="2" face="宋体"/><input name="人数" type="text"/></td>
                  <td width="7%"></td>
                  <td width="17%"><font size="2" face="宋体">类型</font></td>
                  <td width="29%"><select name="类型" size="1">
                        <option value="0">干部</option>
                        <option value="1">群众</option>
                    </select></td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td height="35"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="17%"><font size="2" face="宋体">类型细分</font></td>
                  <td width="30%">
                      <select name="类型细分" size="1">
                      <option value="ld1">科长</option>
                      <option value="ld2">处长</option>
                      <option value="ld3">局长</option>
                      <option value="qz">群众</option>
                    </select></td>
                  <td width="7%"></td>
                  <td width="17%"></td>
                  <td width="29%"></td>
                </tr>
              </table></td>
          </tr>
        </table></td>
  </tr>
</table>
</form>
</xsl:template>
</xsl:stylesheet>

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

<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40" result-ns="">
   <xsl:template>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>变更</TITLE>
<script type="text/javascript" language="javascript">
<xsl:comment>
<![CDATA[
var arr=new Array;
var opts=null;
var opts2=null;
arr[0]=[[’科长’,’ld1’],[’处长’,’ld2’],[’局长’,’ld3’]];
arr[1]=[[’群众’,’qz’]];

function addOption(key){
if(key>arr.length) key=0;
var arrLen=arr[key].length;
for(var i=0;i<arrLen;i++){
var o=new Option(arr[key][i][0],arr[key][i][1],true,false);
opts2.options[opts2.options.length]=o;
}
}

function delOption(){
while(opts2.length>0)
opts2.remove(0);
}

function toChange(){
var key=0;
key=opts[opts.selectedIndex].value;
delOption();
addOption(key);
}

function init(){
opts=document.all.type;
opts2=document.all.type2;
opts.onchange=toChange;
addOption(0);
}
]]>

</xsl:comment>
</script>
</HEAD>
<BODY onload=" init()">
<xsl:apply-templates select="CD/变更"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="变更">
<form name="form1" method="post" action="">
<p></p>
<table width="974" border="0" align="center" cellspacing="0">
  <tr> 
    <td 




推荐文章
联盟网站

浙ICP备 :07003766号 Copyright © 2001-2007 JUBAO163,All rights reserved.