Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

does not update list after resetting and inserting new ...

$
0
0

Hi everyone, after emptying and inserting new options, there are no changes to the video. The code used is the following:

<form asp-controller="DeviceInventoryDataView" asp-action="AppleDeviceDistribution" method="post"><div class="container"><div class="row"><br /></div><div class="row"><div class="col-md-1"><input class="btn btn-info" type="submit" name="dataviewmenu" value="DataView"></div><div class="col-md-1"><input class="btn btn-info" type="submit" name="inventorymenu" value="Home DI"></div><div class="col-md-2"></div><div class="col-md-1"><select id="year" name="year" class="selectpicker" data-width="auto" onchange="getMonthsList()">
                    @{
                        int yId = 1;
                    }
                    @foreach (Dictionary<string, object> year in ViewData["Years"] as List<Dictionary<string, object>>)
                    {
                        if (Convert.ToInt32(year["Year"]) == Convert.ToInt32(ViewData["SelectedYear"])){<option id="@yId" value="@Convert.ToInt32(year["Year"])" selected>@Convert.ToInt32(year["Year"])</option>
                        }
                        else{<option id="@yId" value="@Convert.ToInt32(year["Year"])">@Convert.ToInt32(year["Year"])</option>
                        }
                        yId++;
                    }</select></div><div class="col-md-1" style="text-align:center"><select id="month" name="month" class="selectpicker" data-width="auto" onchange="getDaysList()">
                    @{
                        int mId = 1;
                    }
                    @foreach (Dictionary<string, object> month in ViewData["Months"] as List<Dictionary<string, object>>)
                    {
                        if (Convert.ToString(month["MonthNumber"]) == Convert.ToString(ViewData["SelectedMonthNumber"]))
                        {<option id="@mId" value="@Convert.ToString(month["MonthNumber"])" selected>@Convert.ToString(month["MonthName"])</option>
                        }
                        else
                        {<option id="@mId" value="@Convert.ToString(month["MonthNumber"])">@Convert.ToString(month["MonthName"])</option>
                        }
                        mId++;
                    }</select></div><div class="col-md-1" id="divDay"><select id="day" name="day" class="selectpicker" data-width="auto">
                    @{
                        int dId = 1;
                    }
                    @foreach (Dictionary<string, object> day in ViewData["Days"] as List<Dictionary<string, object>>)
                    {
                        if (Convert.ToString(day["Day"]) == Convert.ToString(ViewData["SelectedDay"]))
                        {<option id="@dId" value="@Convert.ToString(day["Day"])" selected>@Convert.ToString(day["Day"])</option>
                        }
                        else
                        {<option id="@dId" value="@Convert.ToString(day["Day"])">@Convert.ToString(day["Day"])</option>
                        }
                        dId++;
                    }</select></div><div class="col-md-1" style="text-align:right"><input class="btn btn-info" type="submit" name="refresh" value="Refresh"></div><div class="col-md-3">&nbsp;</div><div class="col-md-1"><a href="@Convert.ToString(ViewData["AppleDeviceDistributionExcelPath"])" target="_blank" class="btn btn-success" role="button">Excel Format</a></div></div></div></form><script type="text/javascript">

function getDaysList() {
        var selectedYear = $("#year").val();
        var selectedMonth = $("#month").val();$.ajax({
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json',
            url: '@Url.Action("GetDays", "AjaxDatabaseManager")',
            data: {
                importTable: 'ImportKeys', selectedMonthValue: JSON.stringify(selectedMonth), selectedYearValue: JSON.stringify(selectedYear)
            },
            success: function (result) {
                var optionNumber = 1;

                var resultObj = result; //JSON.parse(result);

                $("#day").empty(); // remove old options
                //$("#day").append("<option id=\"pleaseselectday\" value=\"pleaseSelect\" selected)>Please Select</option>");$.each(resultObj, function (key, val) {$("#day").append("<option id=\"option" + optionNumber + "day\" value=\"" + val + "\" " + (optionNumber == 1 ? "selected" : "") + ">" + val + "</option>");$("#day").trigger("chosen:updated");
                    optionNumber++;
                    alert("Sto facendo append di " + "<option id=\"option" + optionNumber + "day\" value=\"" + val + "\" " + (optionNumber == 1 ? "selected" : "") + ">" + val + "</option>");
                    alert("Il valore selezionato di day è: " + $("#day").val());
                });
            }
        });
    }</script>

This code is within a cshtml file. Basically when I change the value a month I want to reload the day <select>. The problem is only video refresh because the values I expect are correct, in fact when I post the data are transferred correctly.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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