Hallo!
I want to make a calendar, with weekdays and their dates displayed instead of the whole month. So for example “10, Wed”. It’s a week planner, where users also can insert appointments etc.
With a click on a arrow-image I want to display the previous or the next week, as well as wenn I click on the arrow for the month.
My code for now looks like this (I am from Austria, that’s why the german names):
[CODE]var month = [‘Jänner’, ‘Februar’, ‘März’, ‘April’, ‘Mai’, ‘Juni’, ‘Juli’, ‘August’, ‘September’, ‘Oktober’, ‘November’, ‘Dezember’];
function calendar() {
var today = new Date();
setText(‘label’, month[today.getMonth()] + ‘ ‘ + (1900 + today.getYear()));
var day = today.getDay();
if (day !== 01) { // Only manipulate the date if it isn’t Mon.
today.setHours(-24 * (day – 1));
}
setText(‘Mo’, today.getDate());
setText(‘Di’, today.getDate()+1);
setText(‘Mi’, today.getDate()+2);
setText(‘Do’, today.getDate()+3);
setText(‘Fr’, today.getDate()+4);
setText(‘Sa’, today.getDate()+5);
};
function setText(id, val) {
if(val < 10){
val = ‘0’ + val;
}
document.getElementById(id).innerHTML = val;
};
window.onload = calendar;
What’s the best method to display the previous/next week with the correct dates with a click on a arrowimage? I have the same problem with the month. I would need a loop where it sets my current week or month +1 or -1 everytime I click on the arrow/execute the according function.
Setting something +1 or -1 isn’t all so difficult, hehe, but I just don’t know how to “save” the current displayed month/week. So when I click twice on the previous arrow, it should go back two months, and not twice from the same month. I am really not good with loops and arrays and … yeah, stuff. I am quite a programmer-newby ?
So, I would be very thankful for every suggest, example, link or idea how I could approuch my previous/next-functions!
Best wishes
Jackie