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
}//===============================================================
在这个JS里面第3行:AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
这个里面的city.value,get_city_Result_CallBack是调用第6行的function get_city_Result_CallBack(response)
但是这个函数带一个参数response,为什么在第3行调用的时候,不用在city.value,get_city_Result_CallBack后面带参数呀??
那么如果我要在第3行的city.value,get_city_Result_CallBack再带一个参数 i 过去,要怎么样写?
是不是city.value,get_city_Result_CallBack("",i)
然后在第6行的改成function get_city_Result_CallBack(response,i)呀??
但是这样的话,我试过不行!!请问应该怎么改呀??
{
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
}//===============================================================
在这个JS里面第3行:AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
这个里面的city.value,get_city_Result_CallBack是调用第6行的function get_city_Result_CallBack(response)
但是这个函数带一个参数response,为什么在第3行调用的时候,不用在city.value,get_city_Result_CallBack后面带参数呀??
那么如果我要在第3行的city.value,get_city_Result_CallBack再带一个参数 i 过去,要怎么样写?
是不是city.value,get_city_Result_CallBack("",i)
然后在第6行的改成function get_city_Result_CallBack(response,i)呀??
但是这样的话,我试过不行!!请问应该怎么改呀??
你按照它的原型写就可以了,如果原型没提供参数,那么你写了也没用
你 AjaxMethod.GetCityList 里面怎么写的?不会是 get_city_Result_CallBack(city) 吧?
我估计GetCityList 里面也要改
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetCityList(int povinceid)
{
string sql = "select * from city where father=" + povinceid;
return GetDataSet(sql);
}
#endregionGetCityList 是这样的
它固定了我的控件是DropDownList2,我不可能只有一个这样的控件,我还有其它控件都要实现这个功能
所以我想把控件的ID传过去,让他去执行