[js]function buildCal(m, y, cM, cH, cDW, cD, brdr){
var mn=['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'];
var dim=[31,0,31,30,31,30,31,31,30,31,30,31];
var oD = new Date(y, m-1, 1); //DD replaced line to fix date bug when current day is 31st
oD.od=oD.getDay()+1; //DD replaced line to fix date bug when current day is 31st
var todaydate=new Date() //DD added
var scanfortoday=(y==todaydate.getFullYear() && m==todaydate.getMonth()+1)? todaydate.getDate() : 0 //DD added
dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4==0))||(oD.getFullYear()%400==0))?29:28;
var t='<div class="'+cM+'"><table class="'+cM+'" cols="7" cellpadding="0" border="'+brdr+'" cellspacing="0"><tr align="center">';
t+='<td colspan="7" align="center" class="'+cH+'">'+mn[m-1]+' - '+y+'</td></tr><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"NPWŚCPS".substr(s,1)+'</td>';
t+='</tr><tr align="center">';
for(i=1;i<=42;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : ' ';
if (x==scanfortoday) //DD added
x='<span id="today">'+x+'</span>' //DD added
t+='<td class="'+cD+'">'+x+'</td>';
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';
}
return t+='</tr></table></div>';
}[js]
kalendarz wyświetlany jest na przez kod:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> .main { width:200px; border:1px solid black; } .month { background-color:#7d0000;rz</title> font:bold 20px verdana; color:white; } .daysofweek { background-color:#7d0000; font:bold 18px verdana; color:white; } .days { font-size: 18px; font-family:verdana; color:white; background-color: #7d0000; padding: 2px; } .days #today{ font-weight: bold; color: white; } </style> <div style="position: absolute; top:150px; left:270px;"> <script type="text/javascript" src="basiccalendar.js"> /*********************************************** * Basic Calendar-By Brian Gosselin at http://scriptasylum.com/bgaudiodr/ * Script featured on Dynamic Drive (http://www.dynamicdrive.com) * This notice must stay intact for use * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> </head> <body bgcolor="#7D0000" <form> <select onChange="updatecalendar(this.options)"> <script type="text/javascript"> var themonths=['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec', 'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'] var todaydate=new Date() var curmonth=todaydate.getMonth()+1 //get current month (1-12) var curyear=todaydate.getFullYear()+1 //get current year function updatecalendar(theselection){ var themonth=parseInt(theselection[theselection.selectedIndex].value)+1 var calendarstr=buildCal(themonth, curyear, "main", "month", "daysofweek", "days", 0) if (document.getElementById) document.getElementById("calendarspace").innerHTML=calendarstr } for (i=0; i<12; i++) //display option for 12 months of the year document.write('<option value="'+i+'">'+themonths[i]+' '+curyear+'</option>') </script> </select> <div id="calendarspace"> <script> //write out current month's calendar to start document.write(buildCal(1, 2008, "main", "month", "daysofweek", "days", 0)) </script> </div> </form> <div style="position: absolute; top:400px; left:200px;"> </html>
I tu moje pytanie. Chciałbym zaznaczyć niektóre daty( dzień w danym miesiącu) innym kolorem niż wynika ze stylu css. Czy jest taka możliwość? Jeśli tak to proszę o pomoc. Nie musi być koniecznie [js]. Może być kalendarz w php. Z góry dziękuję za pomoc.