两级联动的select XML版
2008-02-23 09:44:58来源:互联网 阅读 ()
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
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash