当前位置:编程学习 > asp >>

两级联动的select XML版

答案:     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
  
  

上一个:在ASP应用程序中限制重复提交同一表单
下一个:披著羊皮的大野狼 Session

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,