login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > JS > Kalenders > handige kalender

handige kalender

Auteur: almar - 01 juli 2006 - 18:56 - Gekeurd door: Gerard - Hits: 6853 - Aantal punten: 3.50 (4 stemmen)





een script wat ik heb aangepast want er zaten veel bugs in.
ik hoop dat je er wat aan hebt

Code:
zet dit in je head:
  1. <script language="JavaScript1.2" type="text/javascript">
  2. <!--
  3. ns4 = (navigator.appName.indexOf("Netscape")>=0 && document.layers)? true : false;
  4. ie4 = (document.all && !document.getElementById)? true : false;
  5. ie5 = (document.all && document.getElementById)? true : false;
  6. ns6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
  7. w3c = (document.getElementById)? true : false;
  8.  
  9.  
  10. var HTMLCode = "";
  11. var DaysList = new Array("","Ma","Di","Wo","Do","Vr","Za","Zo");
  12. var MonthsList = new Array("Mois_Vide","Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
  13. var MonthLength = new Array("Mois_longueur_vide",31,29,31,30,31,30,31,31,30,31,30,31);
  14.  
  15. var QueryDate = 0;
  16. var QueryMonth = 0;
  17. var QueryYear = 0;
  18. var QueryDay = 0;
  19. var FirstDay = 0;
  20. var WeekRef = 0;
  21. var WeekOne = 0;
  22.  
  23. var Today = new Date();
  24. var TodaysYear = Today.getYear();
  25. var TodaysMonth = Today.getMonth() + 1;
  26. var TodaysDate = Today.getDate();
  27. var TodaysDay = Today.getDay() + 1;
  28. if (TodaysYear < 2000) { TodaysYear += 1900; }
  29.  
  30. function CheckData()
  31. {
  32. QueryDate = document.Cal.Date.selectedIndex + 1;
  33. QueryMonth = document.Cal.Month.selectedIndex + 1;
  34. QueryYear = (document.Cal.Century.selectedIndex + 15) * 100 + document.Cal.Year.selectedIndex;
  35. MonthLength[2] = CheckLeap(QueryYear);
  36.  
  37. if ((QueryYear * 10000 + QueryMonth * 100 + QueryDate) < 15821220)
  38. {
  39. alert("Je hebt een datum gekozen van voor Dec 20th 1582.\n\nKies een andere selectie.. zo ver terug gaan we niet !.");
  40. document.Cal.reset();
  41. CheckData();
  42. }
  43. else if (MonthLength[QueryMonth] < QueryDate)
  44. {
  45. alert("Il n'y a pas " + QueryDate + " jours en " + MonthsList[QueryMonth] + " " + QueryYear + " mais " + MonthLength[QueryMonth] + ". \nVeuillez choisir une autre date.");
  46. document.Cal.reset();
  47. CheckData();
  48. }
  49. else { DisplaySchedule(); }
  50.  
  51. }
  52.  
  53.  
  54. function CheckLeap(yy)
  55. {
  56. if ((yy % 100 != 0 && yy % 4 == 0) || (yy % 400 == 0)) { return 29; }
  57. else { return 28; }
  58. }
  59.  
  60.  
  61. function DefWeekNum(dd)
  62. {
  63. numd = 0;
  64. numw = 0;
  65. for (n=1; n<QueryMonth; n++)
  66. {
  67. numd += MonthLength[n];
  68. }
  69. numd = numd + dd - (9 - DefDateDay(QueryYear,1,1));
  70. numw = Math.floor(numd / 7) + 1;
  71.  
  72. if (DefDateDay(QueryYear,1,1) == 1) { numw++; }
  73. return numw;
  74. }
  75.  
  76.  
  77. function DefDateDay(yy,mm,dd)
  78. {
  79. return Math.floor((Date2Days(yy,mm,dd)-2) % 7) + 1;
  80. }
  81.  
  82.  
  83. function Date2Days(yy,mm,dd)
  84. {
  85. if (mm > 2)
  86. {
  87. var bis = Math.floor(yy/4) - Math.floor(yy/100) + Math.floor(yy/400);
  88. var zy = Math.floor(yy * 365 + bis);
  89. var zm = (mm-1) * 31 - Math.floor(mm * 0.4 + 2.3);
  90. return (zy + zm + dd);
  91. }
  92. else
  93. {
  94. var bis = Math.floor((yy-1)/4) - Math.floor((yy-1)/100) + Math.floor((yy-1)/400);
  95. var zy = Math.floor(yy * 365 + bis);
  96. return (zy + (mm-1) * 31 + dd);
  97. }
  98. }
  99.  
  100.  
  101.  
  102. function findid(name,doc){
  103. var i,layer;
  104. for(i=0;i<doc.layers.length;i++){
  105. layer=doc.layers[i];
  106. if(layer.name==name)return layer;
  107. if(layer.document.layers.length>0)if((layer=findid(name,layer.document))!=null)return layer;
  108. }
  109. return null;
  110. }
  111.  
  112.  
  113.  
  114.  
  115. function DisplaySchedule()
  116. {
  117. HTMLCode = "<table cellspacing=0 cellpadding=3 border=1 bordercolor=#404040>";
  118. QueryDay = DefDateDay(QueryYear,QueryMonth,QueryDate);
  119. WeekRef = DefWeekNum(QueryDate);
  120. WeekOne = DefWeekNum(1);
  121. HTMLCode += "<tr align=center><td colspan=8 class=TITRE><b>" + MonthsList[QueryMonth] + " " + QueryYear + "</b></td></tr><tr align=center>";
  122.  
  123. for (s=1; s<8; s++)
  124. {
  125. if (QueryDay == s) { HTMLCode += "<td width=28><b><font color=#FF0000>" + DaysList[s] + "</font></b></td>"; }
  126. else { HTMLCode += "<td width=28><b>" + DaysList[s] + "</b></td>"; }
  127. }
  128.  
  129. HTMLCode += "<td><b><font color=#FF0000>Week</font></b></td></tr>";
  130. a = 0;
  131.  
  132. for (i=(1-DefDateDay(QueryYear,QueryMonth,1)); i<MonthLength[QueryMonth]; i++)
  133. {
  134. HTMLCode += "<tr align=center>";
  135. for (j=1; j<8; j++)
  136. {
  137. if ((i+j) <= 0) { HTMLCode += "<td>&nbsp;</td>"; }
  138. else if ((i+j) == QueryDate) { HTMLCode += "<td><b><font color=#FF9933>" + (i+j) + "</font></b></td>"; }
  139. else if ((i+j) > MonthLength[QueryMonth]) { HTMLCode += "<td>&nbsp;</td>"; }
  140. else { HTMLCode += "<td>" + (i+j) + "</td>"; }
  141. }
  142.  
  143. if ((WeekOne+a) == WeekRef) { HTMLCode += "<td><b><font color=#FF0000>" + WeekRef + "</font></b></td>"; }
  144. else { HTMLCode += "<td><font color=#99CCCC>" + (WeekOne+a) + "</font></td>"; }
  145. HTMLCode += "</tr>";
  146. a++;
  147. i = i + 6;
  148. }
  149.  
  150. // ALLOWS CROSS-BROWSER WRITING IN DOCUMENT. BEGIN BG MODIFY
  151. if(ie4)document.all['Calendrier'].innerHTML = HTMLCode + "</table>";
  152. if(w3c)document.getElementById('Calendrier').innerHTML= HTMLCode + "</table>";
  153. if(ns4){
  154. var tns4=findid('Calendrier',document);
  155. tns4.document.open();
  156. tns4.document.write('<center>'+HTMLCode+'</table></center>');
  157. tns4.document.close();
  158. }
  159. // END BG MODIFY
  160.  
  161. }
  162.  
  163. function Back()
  164. {
  165. document.Cal.Month.selectedIndex = document.Cal.Month.selectedIndex - 1;
  166. if (document.Cal.Month.selectedIndex == -1) { document.Cal.Month.selectedIndex = 11; }
  167. }
  168.  
  169. function Next()
  170. {
  171. document.Cal.Month.selectedIndex = document.Cal.Month.selectedIndex + 1;
  172. if (document.Cal.Month.selectedIndex == -1) { document.Cal.Month.selectedIndex = 0; }
  173. }
  174.  
  175.  
  176. window.onload=CheckData;
  177. if(ns4)window.onresize=function(){
  178. setTimeout('history.go(0)',400);
  179. }
  180.  
  181. //-->
  182. </script>


zet dit in je body
  1. <center>
  2.  
  3.  
  4. <form name="Cal">
  5. <font color="#00FF00">
  6. <script language="JavaScript1.2" type="text/javascript">
  7. <!--
  8.  
  9. DateText = "<select name=\"Date\">"
  10. for (d=1; d<32; d++)
  11. {
  12. DateText += "<option";
  13. if (d == TodaysDate) { DateText += " SELECTED"; }
  14. DateText += ">";
  15. if (d < 10) { DateText += "0"; }
  16. DateText += d + "</option>";
  17. }
  18. DateText += "</select>";
  19. //*************************************************
  20. MonthText = "<select name=\"Month\">"
  21. for (m=1; m<13; m++)
  22. {
  23. MonthText += "<option";
  24. if (m == TodaysMonth) { MonthText += " SELECTED"; }
  25. MonthText += ">";
  26. MonthText += MonthsList[m] + "</option>";
  27. }
  28. MonthText += "</select>";
  29. //*************************************************
  30. CenturyText = "<select name=\"Century\">"
  31. for (c=15; c<25; c++)
  32. {
  33. CenturyText += "<option";
  34. if (c == Math.floor(TodaysYear / 100)) { CenturyText += " SELECTED"; }
  35. CenturyText += ">" + c + "</option>";
  36. }
  37. CenturyText += "</select>";
  38. //*************************************************
  39. YearText = "<select name=\"Year\">";
  40. for (y=0; y<100; y++)
  41. {
  42. YearText += "<option";
  43. if (y == (TodaysYear - Math.floor(TodaysYear / 100) * 100)) { YearText += " SELECTED"; }
  44. YearText += ">";
  45. if (y < 10) { YearText += "0"; }
  46. YearText += y + "</option>";
  47. }
  48. YearText += "</select>";
  49. //*************************************************
  50. document.write(MonthText+' '+DateText+', '+CenturyText+' '+YearText);
  51. //-->
  52. </script> <input type="button" value=" OK " style="font-size: 8 pt" onClick="CheckData()"><br><br>
  53. <input type="button" value="<< Maand" style="font-size: 8 pt" onClick="Back(); CheckData()"><input type="button" value=" Ga terug naar vandaag..." style="font-size: 8 pt" onClick="document.Cal.reset(); setTimeout('CheckData()',100)"><input type="button" value="Maand >>" style="font-size: 8 pt" onClick="Next();CheckData()">
  54. <br><br><br>
  55. <script language="javascript1.2">
  56. if(ns4)document.write('<layer name="Calendrier"></layer><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>')
  57. else document.write('<div id="Calendrier"></div>');
  58. </script>
  59. </font>
  60. </center></form>







Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (2)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.052s