1
我怎樣才能得到第二個列表項值和分配給文本框。例如我的第二個列表項是「編輯配置文件」,然後在textbox1 textchange後,textbox2會自動分配「編輯配置文件」 這裏是我的編碼Jquery獲取列表項
<script language ="javascript" type="text/javascript">
$(document).ready(function() {
$("#TextBox1").bind('change', function (e) {
if ($("#TextBox1").val() != '') {
sendData();
}
});
function sendData() {
var loc = window.location.href;
loc = (loc.substr(loc.length - 1, 1) == "/") ? loc + "t1ViewDB.aspx" : loc;
$.ajax({
type: "POST",
url: loc + "/GetModuleList",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d) {
//Get the second list item and assign value to textbox2
//???
$("#TextBox2").val('');
}
},
error: function() {
alert("An unexpected error has occurred during processing.");
}
});
}
});
</script>
後端代碼
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod()]
public static ArrayList GetModuleList()
{
ArrayList listArr = new ArrayList();
listArr.Add(new ListItem("Dashboard"));
listArr.Add(new ListItem("Edit Profile"));
listArr.Add(new ListItem("Change Password"));
return listArr;
}
嗨,我試試阿迪。 textbox2給我顯示「[object Object]」 – user998405
查看更新..... –
請注意 –