Why text doesn't change in span ? -JQUERY

Hi,
I have two comboboxes where in the first there is month and the other year.
The date “d” must contain today’s date. The date “d2” is the one chosen by the user(my two comoboxes).
The code will have to write “provisional prices” only if we are in the first 5 days of the current month

this is my code (JQUERY):


  $(function() {
                    $("#ddlMonth, #ddlYear").change(function () {    

                // current date
                var d = new Date();
                    d.setHours(0);
                    d.setMinutes(0);
                    d.setSeconds(0);
                    d.setMilliseconds(0);
                        var namedDay = d.getDate();
                        var yearDate = d.getFullYear();
                        var monthDate = d.getMonth() + 1;

                        
                        var d2 = new Date($("#ddlYear").val(), $(this).prop('selectedIndex'));
                        var selectMonth = d2.getMonth() + 1;
                        var selectYear = d2.getFullYear();
                        //var d3 = new Date($("#ddlMonth").val(), $(this).prop('selectedIndex') + 1); 
                        //var d2 = $("#ddlMonth option:selected").val();
                        //var d3 = $("#ddlYear option:selected").val();
                       
                        console.log(selectMonth);
                        console.log(selectYear);
                        console.log(monthDate);  
                        console.log(yearDate);  
                       
                       
                if (selectMonth >= monthDate &&  selectYear >= yearDate ) {    
                    $("#span_result").html("<i class='fa fa-exclamation-triangle'></i> &nbsp; the price are  
provisional");
                    $("#span_result").css("color", "darkred");
                    $("#span_result").css("font-weight", "bold");
                    $("#span_result").css("font-size", "85%");
                }
                else {
                    $("#span_result").html("the price are  consolidate");
                    $("#span_result").css("color", "black");
                    $("#span_result").css("font-weight", "normal");
                    $("#span_result").css("font-size", "85%");
                }

               //If for 5 first days  
                if (namedDay <= 5) {
                    $("#span_result").html("<i class='fa fa-exclamation-triangle'></i> &nbsp; the price are  
provisional");
                    $("#span_result").css("color", "darkred");
                    $("#span_result").css("font-weight", "bold");
                    $("#span_result").css("font-size", "85%");
                 }
                         else {
                    $("#span_result").html("the price are consolidate");
                    $("#span_result").css("color", "black");
                    $("#span_result").css("font-weight", "normal");
                    $("#span_result").css("font-size", "85%");
                        }


                       
       

           });
 
});

Unfortunately, I am unable to carry out concrete tests, could there be any ways to do them?

Thanks!!!

Hi,
Is #dd1Year an input field and maybe put val inside new Date($("#dd1Year").val())?
Greets,
Karin

#ddlYear is one of combobox id and yes the ddlYear value is inside of new Date()

Sorry, missed that bit because I didn’t scroll to the right properly
Greets,
Karin

hi, @camcode.
could you show us your html file?
it will help us to find errors.

Sure but is in aspnet :


        <asp:DropDownList ID="ddlMonth" runat="server">
    <asp:ListItem Text="Jan" Value="01"></asp:ListItem>
    <asp:ListItem Text="Feb" Value="02"></asp:ListItem>
    <asp:ListItem Text="Mar" Value="03"></asp:ListItem>
    <asp:ListItem Text="Apr" Value="04"></asp:ListItem>
    <asp:ListItem Text="May" Value="05"></asp:ListItem>
    <asp:ListItem Text="Jun" Value="06"></asp:ListItem>
    <asp:ListItem Text="Lul" Value="07"></asp:ListItem>
    <asp:ListItem Text="Agu" Value="08"></asp:ListItem>
    <asp:ListItem Text="Set" Value="09"></asp:ListItem>
    <asp:ListItem Text="Oct" Value="10"></asp:ListItem>
    <asp:ListItem Text="Nov" Value="11"></asp:ListItem>
    <asp:ListItem Text="Dic" Value="12"></asp:ListItem>
</asp:DropDownList>
    
    <asp:DropDownList ID="ddlYear" runat="server">
    <asp:ListItem Text="2019" Value="2019"></asp:ListItem>
    <asp:ListItem Text="2020" Value="2020"></asp:ListItem>
    <asp:ListItem Text="2021" Value="2021"></asp:ListItem>
    <asp:ListItem Text="2022" Value="2022"></asp:ListItem>
    <asp:ListItem Text="2023" Value="2023"></asp:ListItem>
    <asp:ListItem Text="2024" Value="2024"></asp:ListItem>
    <asp:ListItem Text="2025" Value="2025"></asp:ListItem>
</asp:DropDownList>

<span id="span_result"></span>

So sorry, @camcode . I am new to asp.