<script> <BR>function link(id) <BR>{ <BR>var obj = document.getElementById(id); <BR>var obj1 = document.getElementById('type2'); <BR>var name = ""; <BR>for(i = 0 ; i < obj.options.length ; i++ ) <BR>{ <BR>if(obj.options[i].selected) <BR>{ <BR>name = obj.options[i].value; <BR>} <BR>} <BR>var names = bargain_class.link(name).value.split(','); <BR>var obj1_count = obj1.options.length <BR>for (i = 0 ; i < obj1_count ; i++) <BR>{ <BR>obj1.options.remove(0); <BR>} <BR>for (i = 0 ; i < names.length ; i ++ ) <BR>{ <BR>option1 = document.createElement("option"); <BR>option1.innerHTML = names[i]; <BR>obj1.appendChild(option1); <BR>} <BR>// alert(names); <BR>} <BR></script>
//后台代码
AjaxPro.Utility.RegisterTypeForAjax(typeof(bargain_class)); //本页页面名
//===============================ajax调用=====================================
[AjaxPro.AjaxMethod]
public string link(string name)
{
string text = "";
string sql = "select name from Management_products_class where pid='" + name + "'";
DataTable dt = LinkSql.conn(sql);
for (int i = 0; i {
if (text == "")
{
text = dt.Rows[i]["name"].ToString();
}
else
{
text += "," + dt.Rows[i]["name"].ToString();
}
}
return text;
}