Hi,
I have filled html drop down like this from sharepoint list
plantvalue_ = $('#' + '<%=ddlplant.ClientID%>').val();
if (plantvalue_ != 0) {
obj.isactive = 1;
obj.plantID = plantvalue_;
obj.siteurl = _spPageContextInfo.siteAbsoluteUrl;
$.ajax({
type: "POST",
url: "/_layouts/15/Dejavu/DejavuUser.aspx/BindDepart",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccessDepart,
failure: function (response) {
alert('Not Try again after refreshing page');
}
});
return false;
}
}
function OnSuccessDepart(response) {
// alert('success');
var ID_exe = '';
var ddl = $("#ddldepart");
ddl.empty().append('<option selected="selected" value="0"> --None-- </option>');
$.each(response.d, function () {
ddl.append($("<option></option>").val(this['m_ID']).html(this['m_Name']));
});
}
its working fine on like below (change event on other list shows "none" which I want to allow user to choose value)
<span>Plant Name</span><asp:DropDownList ID="ddlplant" Width="45%" runat="server" CssClass="select-field" onchange="Bind_Depart();"></asp:DropDownList>
Problem:
when I retrieve data from list (click on edit button) like below code
( using below method on click of edit button its retrieving data fine)
function setui_edit(userid_) {
var obj = {};
obj.userID = userid_;
obj.siteurl = _spPageContextInfo.siteAbsoluteUrl;
obj.Isactive = 1;
obj.Isdeleted = false;
$.ajax({
type: "POST",
url: "/_layouts/15/Dejavu/DejavuUser.aspx/GetUserByID",
// data: '{name: "' + name + '" }',
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccessRetrive,
failure: function (response) {
alert('Not Retrived.Please try again after refreshing page');
}
return false;
}
$('#ddldepart').val(response.d[0].DepartID);
}
its does not set actual data on dropdown list its shows like this...it should set the current value
I am using this to set value " $('#ddldepart').val(response.d[0].DepartID);"... what to do to set current value on dropdown list.
Help me please
Thanks