两级联动的select XML版

2008-02-23 09:44:58来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

XML文件


js文件
var MarketXMLDoc = new ActiveXObject("Msxml2.DOMDocument");
MarketXMLDoc.async = false;
MarketXMLDoc.load("/XML/MARKET_LIST.XML");
function GetMarketList(Type)
{
var Nodes;
switch (Type)
{
case "AllCitys" :
Nodes=MarketXMLDoc.getElementsByTagName("City");
break;
case "AllMarkets" :
Nodes=MarketXMLDoc.getElementsByTagName("Market");
break;
case "TheMarkets" :
CityId=arguments[arguments.length-1];
if(CityId!="")
{
Nodes=MarketXMLDoc.selectNodes(".//City[@RecordNo='" CityId "']//Market");
}
else
{
Nodes=MarketXMLDoc.selectNodes(".//City//Market");
}
break;
default :
break;
}
return Nodes;
}
function ChangeMarkets()
{
CityId=event.srcElement.options[event.srcElement.selectedIndex].value;
GenerateMarketList("TheMarkets","Market","","",CityId)
}
function ChangeMarketsEx()
{
CityId=event.srcElement.options[event.srcElement.selectedIndex].value;
GenerateMarketListEx("TheMarkets","_Market","","",CityId)
}
function GenerateMarketList(Type,Name,Style,Class)
{
var oList,oItem;
var CityId=arguments[arguments.length-1];
var Nodes=GetMarketList(Type,CityId);
if(Nodes.length==0) return;
switch (Type)
{
case "AllCitys" :
case "AllMarkets" :
oList=document.createElement("SELECT");
oList.style.cssText=Style;
oList.className=Class;
oList.name=Name;
oList.id=Name;
oList.onchange=(Type=="AllCitys"?"ChangeMarkets()":"");
break;
case "TheMarkets" :
oList=document.getElementsByName(Name)[0];
oList.innerHTML="";
break;
default :
break;
}
oItem=document.createElement("OPTION");
oItem.value="";
oItem.innerText="-搜索所有-";
oList.appendChild(oItem);
for(i=0;i {
oItem=document.createElement("OPTION");
oItem.value=Nodes[i].getAttribute("RecordNo");
oItem.innerText=Nodes[i].getAttribute("Name");
oList.appendChild(oItem);
}
return oList;
}
function InputAddress()
{
NewValue=event.srcElement.options[event.srcElement.selectedIndex].text
document.getElementById("Address1").value =NewValue;
}
function GenerateMarketListEx(Type,Name,Style,Class,Callback)
{
var oList,oItem;
var CityId=arguments[arguments.length-1];
var Nodes=GetMarketList(Type,CityId);
if(Nodes.length==0) return;
switch (Type)
{
case "AllCitys" :
case "AllMarkets" :
oList=document.createElement("SELECT");
oList.style.cssText=Style;
oList.className=Class;
oList.name=Name;
oList.id=Name;
oList.onchange=((Type=="AllCitys"?"ChangeMarketsEx();":"") Callback);
break;
case "TheMarkets" :
oList=document.getElementsByName(Na

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:披著羊皮的大野狼 Session

下一篇:在Windows 2000中配置ASP开发环境