locked
not display the dropdown list inthis code RRS feed

  • Question

  • User1665719730 posted


    <script src="js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    var SectorDDL = $("#<%=ddl_Sector.ClientID%>");
    var JobroleDDL = $("#<%=ddl_JobRoleName.ClientID%>");

    $.ajax({
    url: 'Getdropdowns.asmx/GetSectors1',
    method: 'post',
    dataType: 'json',
    success: function (data) {
    SectorDDL.append($('<option/>', { value: 0, text: 'Select Sector' }));

    JobroleDDL.append($('<option/>', { value: 0, text: 'Select Jobrole' }));

    JobroleDDL.prop('Enable', true);

    $(data).each(function (index, item) {
    SectorDDL.append($('<option/>', { value: item.SectorId, text: item.SectorFullName }));
    });
    },
    error: function (err) {
    alert(err);
    }
    });

    SectorDDL.change(function () {
    if ($(this).val() == "0") {
    JobroleDDL.empty();
    JobroleDDL.append($('<option/>', { value: 0, text: 'Select Jobrole' }));
    JobroleDDL.val('0');
    JobroleDDL.prop('Enable', true);
    }
    else {
    $.ajax({
    url: 'Getdropdowns.asmx/GetJobroleBySectorId',
    method: 'post',
    dataType: 'json',
    data: { SectorId: $(this).val() },
    success: function (data) {
    JobroleDDL.empty();
    JobroleDDL.append($('<option/>', { value: 0, text: 'Select Jobrole' }));
    $(data).each(function (index, item) {
    JobroleDDL.append($('<option/>', { value: item.JobRoleId, text: item.JobRoleFullName }));
    });
    JobroleDDL.val('0');
    JobroleDDL.prop('Enable', false);
    },
    error: function (err) {
    alert(err);
    }
    });
    }
    });

    Bindgrid();
    $("#<%=ddl_Sector.ClientID%>").change(function () {
    $('#gv_Batches').empty();
    Bindgrid();
    });
    $("#<%=ddl_JobRoleName.ClientID%>").change(function () {
    $('#gv_Batches').empty();
    Bindgrid();
    });
    $("#<%=txt_AssessmentDate.ClientID%>").change(function () {
    $('#gv_Batches').empty();
    Bindgrid();
    });
    $("#<%=txt_SDMSId.ClientID%>").keyup(function () {
    $('#gv_Batches').empty();
    Bindgrid();
    });
    });
    </script>
    <script type="text/javascript">
    function Bindgrid() {
    var Assessment_Date = $("#<%=txt_AssessmentDate.ClientID%>").val();
    if (Assessment_Date.length == 0) {
    Assessment_Date = "1/1/1900 12:00:00";
    }
    var Sector_Id = $("#<%=ddl_Sector.ClientID%>").val();
    if (Sector_Id == null || Sector_Id=="")
    {
    Sector_Id = 0;
    }
    var JobRole_Id = $("#<%=ddl_JobRoleName.ClientID%>").val();
    if (JobRole_Id == null || JobRole_Id=="")
    {
    JobRole_Id = 0;
    }
    var SDMS_Id = $("#<%=txt_SDMSId.ClientID%>").val();
    var page_Index = 1;
    $.ajax({
    url: 'Getdropdowns.asmx/Admin_GetUsersWithSearch',
    method: 'post',
    dataType: 'json',
    data: {
    AssessmentDate: Assessment_Date,
    SectorId: Sector_Id,
    JobRoleId: JobRole_Id,
    SDMSId: SDMS_Id,
    PageIndex: page_Index
    },
    success: function (data) {
    $('#gv_Batches').dataTable({
    paging: false,
    sort: true,
    searching: false,
    processing: true,
    destroy:true,
    data: data,
    columns: [
    { 'data': 'BatchId' },
    { 'data': 'SDMSId' },
    { 'data': 'SectorName' },
    { 'data': 'JobRoleName' },
    { 'data': 'State' },
    { 'data': 'City' },
    {
    'data': 'AssessmentStartDate',
    'render': function (Assessment_Date) {
    var date = new Date(Assessment_Date);
    var month = date.getMonth() + 1;
    return (month.length > 1 ? month : "0" + month) + "/" + date.getDate() + "/" + date.getFullYear();
    }
    },
    {
    'data': 'BatchId',
    'render': function (BatchId) {
    var encodedUrl = encodeURIComponent(BatchId);
    return '<a href=user_details_edit.aspx?dmFsdWUxfHZhbHVlMnx2YWx1ZTM=' + encodedUrl + '>Download Candidates</a>';
    }
    }
    ]
    });
    }
    });
    }

    </script>

    </asp:Content>

    Thursday, October 4, 2018 10:18 AM

All replies

  • User475983607 posted

    not display the dropdown list inthis code

    This statement is not descriptive enough.  Which dropdown is not displaced?

    Please attempt basic troubleshooting rather than dumping code on the forum with a vague problem statement.   There are too many possible issues with the posted code and there's no markup or code behind.  All we can do is look at the JavaScript and guess and assume.  It is up to you to narrow down the issue.

    Open the browser's developer tools to view the network and console to look for errors.   Place a break point in the asmx and verify if the web methods are invoked.  Explain the steps to reproduce the issue.  Also explain all 3rd party APIs.  At the very least, post sample code that reproduces the issue.

    Thursday, October 4, 2018 10:56 AM