DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> script不刷新頁面的聯動前後代碼
script不刷新頁面的聯動前後代碼
編輯:關於JavaScript     
復制代碼 代碼如下:
<asp:DropDownList ID="type1" runat="server" CssClass="tfont" onchange="link(this.id);" </asp:DropDownList>
<%-- 大小類--%>
<script>
function link(id)
{
var obj = document.getElementById(id);
var obj1 = document.getElementById('type2');
var name = "";
for(i = 0 ; i < obj.options.length ; i++ )
{
if(obj.options[i].selected)
{
name = obj.options[i].value;
}
}
var names = bargain_class.link(name).value.split(',');
var obj1_count = obj1.options.length
for (i = 0 ; i < obj1_count ; i++)
{
obj1.options.remove(0);
}
for (i = 0 ; i < names.length ; i ++ )
{
option1 = document.createElement("option");
option1.innerHTML = names[i];
obj1.appendChild(option1);
}
// alert(names);
}
</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 < dt.Rows.Count; i++)
{
if (text == "")
{
text = dt.Rows[i]["name"].ToString();
}
else
{
text += "," + dt.Rows[i]["name"].ToString();
}
}
return text;
}
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved