Hello Guys i am using a web service and ajax call to bind my cascading drop down lists but i am not able to get the selected value of first drop down in code behind..
this is my code
$(document).ready(function () {
var groups = $('#ddlGrpName');
var docs = $('#ddlDoctors');
//var getval = $('#ddlGrpName').val();
//var anothrva = $('#ddlDoctors').val();
$.ajax({
url: 'Dataservice.asmx/GetGroups',
method: 'post',
dataType: 'json',
success: function (data) {
groups.append($('<option/>', { value: -1, text: 'select Group' }));
docs.append($('<option/>', { value: -1, text: 'select Doctor' }));
docs.prop('disabled', true);
$(data).each(function (index, item) {
groups.append($('<option/>', { value: item.id, text: item.name }));
$('#<%=hdnGroupid.ClientID%>').val(item.id);
});
}
});
groups.change(function () {
if ($(this).val() == "-1") {
docs.empty();
docs.append($('<option/>', { value: -1, text: 'select Doctor' }));
docs.val('-1');
docs.prop('disabled', true);
}
else {
$.ajax({
url: 'Dataservice.asmx/GetGroupsid',
method: 'post',
data: { groupID: $(this).val() },
dataType: 'json',
success: function (data) {
docs.empty();
docs.append($('<option/>', { value: -1, text: 'select Doctor' }));
docs.prop('disabled', false);
$(data).each(function (index, item) {
docs.append($('<option/>', { value: item.id, text: item.pname }));
$('#<%=hdnDoctorid.ClientID%>').val(item.id);
});
}
});
}
});
});
drop down values are binding but not able to get the selected value of drop down while saving in the database. this are two cascading drop downs i am getting the value of second drop down when i take a hidden field , but when i check the same way with the first drop down i am only getting the same value , but drop down selected value changes whenever i change the drop down its not happening
please help??