用ajaxpro实现多级dropdownlist无刷新联动后,获取dropdownlist选中项的值出错
用ajaxpro绑定dropdownlist方法:[AjaxPro.AjaxMethod]publicDataSetGetCityData(stringproid){st...
用ajaxpro绑定dropdownlist方法:
[AjaxPro.AjaxMethod]
public DataSet GetCityData(string proid)
{
string getCity = "select * from zd_synthesis t where t.dictionary=100025 and t.pitemid=" + proid;
DataSet ds = jklmAdmin.Helper.DataHelper.ExecuteDataset(getCity);
return ds;
}
JS代码:
function BindToCity(ProvinceID,DDL_City_ID)
{
var DataSet_City = Admin_SPConsult_SPConsult_Applay.GetCityData(ProvinceID).value;//注意加Value
var DDL_City = document.getElementById(DDL_City_ID);
DDL_City.length = 0;//清除已有选项
DDL_City.options.add(new Option("--请选择--",0));
var Length = DataSet_City.Tables[0].Rows.length;
if(Length!=0)
{
for(var i=0;i <Length;i++)
{
var Text = DataSet_City.Tables[0].Rows[i].ITEMNAME;//必须和DataSet的列名一致
var Value = DataSet_City.Tables[0].Rows[i].ITEMID;
DDL_City.options.add(new Option(Text,Value));
}
}
else
{
var DDL_Area = document.getElementById("ddlHp");
DDL_Area.length = 0;
};
return;
}
实现了dropdownlist无刷新多级联动,但是获取dropdownlist值时出错,查看页面源代码发现
<select name="ddlCity" id="ddlCity" onchange="BindToHP(this.options[selectedIndex].value,'ddlHp');">
<option value="-1">--请选择--</option>
</select>市</td>
并没有数据,请问这种情况下怎么获取dropdownlist选中项的值呢? 展开
[AjaxPro.AjaxMethod]
public DataSet GetCityData(string proid)
{
string getCity = "select * from zd_synthesis t where t.dictionary=100025 and t.pitemid=" + proid;
DataSet ds = jklmAdmin.Helper.DataHelper.ExecuteDataset(getCity);
return ds;
}
JS代码:
function BindToCity(ProvinceID,DDL_City_ID)
{
var DataSet_City = Admin_SPConsult_SPConsult_Applay.GetCityData(ProvinceID).value;//注意加Value
var DDL_City = document.getElementById(DDL_City_ID);
DDL_City.length = 0;//清除已有选项
DDL_City.options.add(new Option("--请选择--",0));
var Length = DataSet_City.Tables[0].Rows.length;
if(Length!=0)
{
for(var i=0;i <Length;i++)
{
var Text = DataSet_City.Tables[0].Rows[i].ITEMNAME;//必须和DataSet的列名一致
var Value = DataSet_City.Tables[0].Rows[i].ITEMID;
DDL_City.options.add(new Option(Text,Value));
}
}
else
{
var DDL_Area = document.getElementById("ddlHp");
DDL_Area.length = 0;
};
return;
}
实现了dropdownlist无刷新多级联动,但是获取dropdownlist值时出错,查看页面源代码发现
<select name="ddlCity" id="ddlCity" onchange="BindToHP(this.options[selectedIndex].value,'ddlHp');">
<option value="-1">--请选择--</option>
</select>市</td>
并没有数据,请问这种情况下怎么获取dropdownlist选中项的值呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询