/*xml文件格式*/
<?xml version="1.0" encoding="GBK" ?>
<root>
<%int b=0;%>
  <c:forEach items="${optionsListBean.lstItems}" var="z">
    <values value="<c:out value="${z.strKey}"/>" code="<c:out value="${z.strCode}"/>"  ParentId="<c:out value="${z.strParentId}"/>" name="<c:out value="${z.strName}"/>" <%if(b%2==0){%>bgColor="#ECF5FE"<%}%><%if(b%2==1){%>bgColor="#FFFFFF"<%}%><%b=b+1;%> Num="<%=b%>"/>
  </c:forEach>
 </root>
<!--
/***********************************************
函数名: funGetValues1
作者:赵晓阳
做成日期: 2004-02-17
修改者/日期:
参数:   name: 列表名
                srcDlt: 列表ID
                code: 代码
功能描述:根据参数查数据库中的列表项
************************************************/
function funGetValues(name,srcDlt,cncode,code,key)
{
        var sels=srcDlt;
        if(sels.tagName!="SELECT")
          sels=srcDlt.parentElement.parentElement.cells[0].children[0];        sels.innerHTML="";
        var xmldoc = new ActiveXObject("msxml");
        var xmlsrc = "/scheduler/jsp/include/OptKeyNameXml.jsp?Name="+name+"&Code="+code+"&CnCode="+cncode+"&Key="+key;
        xmldoc.URL = xmlsrc;
        var root=xmldoc.root;
        var children=root.children;
        //<!--没有符合条件的记录时,提示-->
        if(children==null){
          var opts=document.createElement("OPTION");
                sels.options.add(opts);
                opts.value="";
                opts.text="";
                sels.options[0].selected;
                sels.focus();
                return false;
        }
        //<!--将结果写入ShipId下拉列表框-->
        var rootLength=children.length;
        for(var i=0;i<rootLength;i++)
        {
                var opts=document.createElement("OPTION");
                sels.options.add(opts);
                opts.value=children.item(i).getAttribute("value");
                opts.code=children.item(i).getAttribute("code");
                opts.name=children.item(i).getAttribute("name");
                opts.parentId=children.item(i).getAttribute("ParentId");
                opts.text=children.item(i).getAttribute("name");
        }
        sels.options[0].selected;
        sels.focus();
        return false;
}//-->

解决方案 »

  1.   

    <!--common_query.xml-->
    <?xml version="1.0" encoding="gb2312"?>
    <root>
    <table name="s0" value="v0"></table>
    <table name="s1" value="v1"></table>
    <table name="s2" value="v2"></table>
    <table name="s3" value="v3"></table>
    </root>
        var loXML = new ActiveXObject("Microsoft.XMLDOM");
        loXML.async = false;
        loXML.load("common_query.xml");
        xmlObj=loXML.documentElement;
        coll.options.length=0;
        for(var i=0;i<xmlObj.childNodes.length;i++){
          var v1=xmlObj.childNodes(i).getAttribute("name");
          var v2=xmlObj.childNodes(i).getAttribute("value");
          coll.options[coll.options.length]=new Option(v1,v2);
        }