X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=html%2Finclude%2Fcalendar.js;h=830deb078ff93b63c6d001ff7961bde105e02fd7;hb=0e28209ef4096662e03da00134ba7ce0c5fff531;hp=b6f7296c0a97ef7c07a03d07c209ac65ed9350c8;hpb=e299f0ca47a924516f2afbe4e922f2418b75315c;p=gosa.git diff --git a/html/include/calendar.js b/html/include/calendar.js index b6f7296c0..830deb078 100644 --- a/html/include/calendar.js +++ b/html/include/calendar.js @@ -1,34 +1,37 @@ function populate(objForm,resultForm) { - yearSel=objForm.year.options[objForm.year.selectedIndex].text; - monthIx=objForm.month.selectedIndex; - nextMonthIx=0; - if(monthIx!=11) - nextMonthIx=monthIx+1; - - nextMonthSel=objForm.month.options[nextMonthIx].value; - monthSel=objForm.month.options[monthIx].value; - - daySel=1; - if(objForm.day.selectedIndex!=-1) - daySel=objForm.day.options[objForm.day.selectedIndex].value; - - timeOfDayOne = new Date(yearSel, nextMonthSel, 1); - timeDifference = timeOfDayOne - 86400000; - timeOfLastDay = new Date(timeDifference); - - var daysInMonth = timeOfLastDay.getDate(); - - if(daySel>daysInMonth) daySel=daysInMonth; - - selectedDate= new Date(yearSel,monthSel,daySel); - for (var i = 0; i < objForm.day.length; i++) { - objForm.day.options[0] = null; - } - for (var i = 0; i < daysInMonth; i++) { - objForm.day.options[i] = new Option(i+1); + if(objForm.year) { + yearSel=objForm.year.options[objForm.year.selectedIndex].text; + + monthIx=objForm.month.selectedIndex; + nextMonthIx=0; + if(monthIx!=11) + nextMonthIx=monthIx+1; + + nextMonthSel=objForm.month.options[nextMonthIx].value; + monthSel=objForm.month.options[monthIx].value; + + daySel=1; + if(objForm.day.selectedIndex!=-1) + daySel=objForm.day.options[objForm.day.selectedIndex].value; + + timeOfDayOne = new Date(yearSel, nextMonthSel, 1); + timeDifference = timeOfDayOne - 86400000; + timeOfLastDay = new Date(timeDifference); + + var daysInMonth = timeOfLastDay.getDate(); + + if(daySel>daysInMonth) daySel=daysInMonth; + + selectedDate= new Date(yearSel,monthSel,daySel); + for (var i = 0; i < objForm.day.length; i++) { + objForm.day.options[0] = null; + } + for (var i = 0; i < daysInMonth; i++) { + objForm.day.options[i] = new Option(i+1); + } + objForm.day.selectedIndex=daySel-1; + saveResult(selectedDate,resultForm); } - objForm.day.selectedIndex=daySel-1; - saveResult(selectedDate,resultForm); } function createResult(objForm,resultForm){