Hey guys, I'm working on a calendar style program and I'm trying to set it up so that when I pick a date it will automatically display 3 days ahead of the day picked skipping saturdays and sundays. I'm still a newbie so I'm trying to do it using an array that is almost 3 weeks in length and the loop will simply go through the array and add 3 days excluding saturday and sunday. I havn't gotten to excluding saturday and sunday quite yet though as I'm struggling to just get the day to display correctly. I'm just trying to display the day in a textbox for now. Heres some of my code:
I have I've done a few tests on my code so far and what I think is wrong is the if statement comparing the day object (a simple option list) with the "week" array. That seems to stop the code so that nothing after it works properly. Can anyone help?
Code:
function sell(day){
var i = 0;
var index = 0;
week = new Array(21);
week[0] = "sunday";
week[1] = "monday";
week[2] = "teusday";
week[3] = "wednesday";
week[4] = "thursday";
week[5] = "friday";
week[6] = "saturday";
week[7] = "sunday";
week[8] = "monday";
week[9] = "teusday";
week[10] = "wednesday";
week[11] = "thursday";
week[12] = "friday";
week[13] = "saturday";
week[14] = "sunday";
week[15] = "monday";
week[16] = "teusday";
week[17] = "wednesday";
week[18] = "thursday";
week[19] = "friday";
week[20] = "saturday";
for (i=0; i<8; i++){
if (day.options[day.selectedIndex].value == week[i])
index = i;
}
document.getElementById("testdisplay").innerText = week[index + 3];
}