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> 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> 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!!!