Hi,
I have these two functions which have mostly similar code.. so I want to combine them into one function.. any help appreciated.
I have these two functions which have mostly similar code.. so I want to combine them into one function.. any help appreciated.
JavaScript:
previousMonthImg.onclick = function() {
if (!(monthSelect.value === "Jan" && yearSelect.value === "2010")) {
monthSelect.selectedIndex--;
if (monthSelect.selectedIndex === -1) {
monthSelect.value = "Dec";
yearSelect.selectedIndex--;
}
}
triggerEvent(monthSelect, "change");
triggerEvent(yearSelect, "change");
};
JavaScript:
nextMonthImg.onclick = function() {
if (!(monthSelect.value === "Dec" && yearSelect.value === "2030")) {
monthSelect.selectedIndex++;
if (monthSelect.selectedIndex === -1) {
monthSelect.value = "Jan";
yearSelect.selectedIndex++;
}
}
triggerEvent(monthSelect, "change");
triggerEvent(yearSelect, "change");
}