How can i get the second list item value and assign to the textbox.For example my second list item is “edit profile” ,then after the textbox1 textchange, the textbox2 will auto assign “edit profile”
Here is my coding
<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>
backend code
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;
}
Just reference by index:
Arraylist and webmethod