Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

i need to set html drop down list value on retrive data from list..

$
0
0

Hi,

I have filled html drop down like this from sharepoint list

  function Bind_Depart() {
        plantvalue_ = $('#' + '<%=ddlplant.ClientID%>').val();
         if (plantvalue_ != 0) {
            var obj = {};
            obj.isactive = 1;
            obj.plantID = plantvalue_;
            obj.siteurl = _spPageContextInfo.siteAbsoluteUrl;
            //  alert(obj.name);
            $.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;
    }
    function OnSuccessRetrive(response) {
        if (response.d.length > 0) {
           Bind_Depart();
            $('#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



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>