Ajax實(shí)現(xiàn)無(wú)刷新三聯(lián)動(dòng)下拉框
2024-09-01 08:29:41
供稿:網(wǎng)友
 
<HTML> 
<HEAD> 
<title>Ajax實(shí)現(xiàn)無(wú)刷新三聯(lián)動(dòng)下拉框</title> 
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> 
<meta content="C#" name="CODE_LANGUAGE"> 
<meta content="JavaScript" name="vs_defaultClientScript"> 
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> 
<SCRIPT language="javascript">  
//城市------------------------------ 
function cityResult()  
{  
var city=document.getElementById("DropDownList1"); 
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack); 
} 
function get_city_Result_CallBack(response) 
{ 
if (response.value != null) 
{  
//debugger; 
document.all("DropDownList2").length=0;      
     var ds = response.value; 
if(ds != null && typeof(ds) == "object" && ds.Tables != null) 
{  
for(var i=0; i<ds.Tables[0].Rows.length; i++) 
     { 
     var name=ds.Tables[0].Rows[i].city; 
       var id=ds.Tables[0].Rows[i].cityID; 
       document.all("DropDownList2").options.add(new Option(name,id)); 
     } 
} 
}  
return 
} 
//市區(qū)---------------------------------------- 
function areaResult()  
{  
var area=document.getElementById("DropDownList2"); 
AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack); 
} 
function get_area_Result_CallBack(response) 
{ 
if (response.value != null) 
{  
document.all("DropDownList3").length=0;      
     var ds = response.value; 
if(ds != null && typeof(ds) == "object" && ds.Tables != null) 
{  
for(var i=0; i<ds.Tables[0].Rows.length; i++) 
     { 
       var name=ds.Tables[0].Rows[i].area; 
       var id=ds.Tables[0].Rows[i].areaID; 
       document.all("DropDownList3").options.add(new Option(name,id)); 
     }  
} 
} 
return 
} 
function getData() 
{ 
var province=document.getElementById("DropDownList1"); 
var pindex = province.selectedIndex; 
var pValue = province.options[pindex].value; 
var pText = province.options[pindex].text; 
var city=document.getElementById("DropDownList2"); 
var cindex = city.selectedIndex; 
var cValue = city.options[cindex].value; 
var cText = city.options[cindex].text; 
var area=document.getElementById("DropDownList3"); 
var aindex = area.selectedIndex;