asp.Netにおけるjs+jquery追加ドロップダウンボックス値とバックグラウンド取得例

3248 ワード

 
  


<br/><script src="Scripts/jquery-1.4.1.js" type="text/javascript"/> <br/><script type="text/javascript"> <br>$(function () { <br>$(".cg2").change(function () { <br>var id = $(this).attr("id"); <br>var value = $(this).val(); <br>var newid = '#'+id.replace('_1_', '_2_');// id id <br>//alert(newid); <br>var data = "t1*v1|t2*v2|t3*v3";// , <br>var datas = data.split('|');// <br>for (var i = 0; i < datas.length; i++) { <br>var d1 = datas[i].split('*');// <br>$(newid).append("<option value=\""+d1[1]+"\">" + d1[0] + "</option>"); <br>//alert(d1); <br>} <br>// alert(id + "|||" + value); <br>}); <br>}) <br> <br></script> <br/> <br/> <br/><form id="form1" runat="server"> <br/><div> , 。 , 。 js+jquery, +Ajax , <br/><dropdownlist id="ddl_1_1" cssclass="cg2" runat="server"> <br/><listitem text="txt1" value="val1"/> <br/><listitem text="txt1" value="val1"/> <br/><listitem text="txt1" value="val1"/> <br/></dropdownlist> <br/><dropdownlist id="ddl_2_1" runat="server"> <br/></dropdownlist><br/> <br/><dropdownlist id="ddl_1_2" cssclass="cg2" runat="server"> <br/><listitem text="txt2" value="val2"/> <br/><listitem text="txt2" value="val2"/> <br/><listitem text="txt2" value="val2"/> <br/></dropdownlist> <br/><dropdownlist id="ddl_2_2" runat="server"> <br/></dropdownlist><br/> <br/><button id="ButtonGet" runat="server" text=" " onclick="ButtonGet_Click"/> <br/><label id="Label1" runat="server" text=""/> <br/></div> <br/></form> <br/> <br/> <br/> <br/>// <br/> <br/>protected void Page_Load(object sender, EventArgs e) <br/>{ <br/>if (!IsPostBack) <br/>{ <br/> <br/>} <br/>} <br/> <br/>protected void ButtonGet_Click(object sender, EventArgs e) <br/>{ <br/>/// js ddl_2_1 , Label1 。 <br/>Label1.Text = Request["ddl_2_1"].ToString(); <br/>} <br/> </code></pre> <div class="clearfix"> <span id="art_bot" class="jbTestPos"/> </div> </div> </div> </div>