两级联动的select XML版

发表于:2007-06-30来源:作者:点击数: 标签:
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=MarketXMLDo
   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

原文转自:http://www.ltesting.net