最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp.net中js+jquery添加下拉框值和后臺(tái)獲取示例

 更新時(shí)間:2014年05月15日 16:45:09   作者:  
這篇文章主要介紹了asp.net中js+jquery添加下拉框值和后臺(tái)獲取的具體實(shí)現(xiàn),需要的朋友可以參考下
復(fù)制代碼 代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(".cg2").change(function () {
var id = $(this).attr("id");
var value = $(this).val();
var newid = '#'+id.replace('_1_', '_2_');//把第一列id替換成第二列id
//alert(newid);
var data = "t1*v1|t2*v2|t3*v3";//后臺(tái)獲取的數(shù)據(jù)格式,這里用固定值了
var datas = data.split('|');//分割成多組
for (var i = 0; i < datas.length; i++) {
var d1 = datas[i].split('*');//每組分割成 顯示值和真實(shí)值
$(newid).append("<option value=\""+d1[1]+"\">" + d1[0] + "</option>");
//alert(d1);
}
// alert(id + "|||" + value);
});
})

</script>
</head>
<body>
<form id="form1" runat="server">
<div>為了滿足兩列,任意多行。后臺(tái)動(dòng)態(tài)生成下拉框,還要前后列聯(lián)級(jí)的需求。使用js+jquery,用服務(wù)器控件+Ajax也不行,老是選擇之后就
<asp:DropDownList ID="ddl_1_1" CssClass="cg2" runat="server">
<asp:ListItem Text="txt1" Value="val1"></asp:ListItem>
<asp:ListItem Text="txt1" Value="val1"></asp:ListItem>
<asp:ListItem Text="txt1" Value="val1"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddl_2_1" runat="server">
</asp:DropDownList><br/>
<asp:DropDownList ID="ddl_1_2" CssClass="cg2" runat="server">
<asp:ListItem Text="txt2" Value="val2"></asp:ListItem>
<asp:ListItem Text="txt2" Value="val2"></asp:ListItem>
<asp:ListItem Text="txt2" Value="val2"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddl_2_2" runat="server">
</asp:DropDownList><br/>
<asp:Button ID="ButtonGet" runat="server" Text="獲取" onclick="ButtonGet_Click" />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>

//后臺(tái)

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}

protected void ButtonGet_Click(object sender, EventArgs e)
{
///獲取通過js加選擇的 ddl_2_1 控件選中的值,顯示在Label1上。
Label1.Text = Request["ddl_2_1"].ToString();
}

相關(guān)文章

最新評(píng)論

五常市| 和平区| 江山市| 乐亭县| 凉山| 双峰县| 门头沟区| 邻水| 同德县| 定襄县| 敖汉旗| 铁力市| 邵阳县| 醴陵市| 新野县| 贵阳市| 神农架林区| 保德县| 卓资县| 汉沽区| 昆明市| 黄冈市| 阳朔县| 安义县| 科技| 共和县| 汶上县| 兰西县| 黄大仙区| 余庆县| 丹江口市| 杨浦区| 楚雄市| 开封县| 翼城县| 夏津县| 津市市| 佛山市| 石景山区| 湘阴县| 泸溪县|