js 代码
function GetAreaList(res1,res2)
{
var CityID = res1.options[res1.selectedIndex].value;
res2.length=0;
var ds = Property_Default.GetArea(CityID).value;
if(ds != null&& typeof(ds) == "object" && ds.Tables != null)
{
if(res1.selectedIndex != 0)
{
for(var i=1; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].AreaName;
var id=ds.Tables[0].Rows[i].AreaID;
res2.options.add(new Option(name,id));
}
}
else
{
res2.options.add(new Option("选择区域","0"));
}
}
}
cs 代码
[AjaxPro.AjaxMethod]//获得区域数据
public DataSet GetArea(int CityID)
{
string str = "select * from ktv_Area where CityID=" + CityID;
DataSet ds = DataBase.ExeSqlda(str);
return ds;
}
private DataSet GetData()
{
string str = "select * from property_City";
DataSet ds = DataBase.ExeSqlda(str);
return ds;
}
本文介绍了一个JS函数,用于从下拉列表中获取选中的城市ID,并调用CS端的服务来获取该城市的区域数据。具体实现包括了JS端处理数据展示以及CS端通过SQL查询返回数据集。
4118

被折叠的 条评论
为什么被折叠?



