PDA

View Full Version : Basic Calendar w/ some mods



jeffgreco1101
04-17-2007, 11:28 PM
Alright I'm using the basic calendar script from this site and ive made a couple modifications of my own... like made each date a link for further info and such. But what I am trying to do is put some "Previous" and "Next" buttons so change the months automatically. Here's what I have...


<style type="text/css">
A {
text-decoration: underline;
color:black;
font-size: 14px;
}

A:hover {
text-decoration: none;
color:#FFFFFF;
font-size: 14px;
}


iframe {
border:1;
border-style:solid;
border-color:black;
border-width:1px 1px 1px 1px;
}

.main {

border:1px solid black;
}

.month {
background-color:black;
font:bold 14px verdana;
color:white;
}

.daysofweek {
cursor: hand;
background-color:gray;
font:bold 15px verdana;
color:white;
}

.days {
cursor: hand;
font-size: 11px;
font-family:verdana;
color:black;
background-color: C0C0C0;
padding: 2px;
}

.days #today{
cursor: hand;
font-weight: bold;
color: red;
}

</style>

<script type="text/javascript">
var loader=1;

var todaydate=new Date()
var curmonth=todaydate.getMonth()+1 //get current month (1-12)
var curyear=todaydate.getFullYear() //get current year

</script>
<!--##########################################################################-->
<script type="text/javascript">
function buildCal(m, y, cM, cH, cDW, cD, brdr,wid,hht,which){
var mn=['January','February','March','April','May','June','July','August','September','October','November','December'];
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 width="'+wid+'" height="'+hht+'" 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+'">'+"SMTWTFS".substr(s,1)+'</td>';
t+='</tr><tr>';
for(i=1;i<=42;i++){
var h2=84;
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : '';
var x2=x;

var eve="";
if (x2>31 || x2=="") {
x2=0;
h2=30;
}
if (x2==7 || x2==9 || x2==16 || x2==28) {
eve="Events";
}
if (x==scanfortoday) //DD added
x='<span id="today">'+x+'</span>' //DD added
if (which==1) {
t+='<td width="110" height="'+h2+'" valign="top" class="'+cD+'"><a href="'+mn[m-1]+'/day'+x2+'.html" target="calEvents">'+x+'</a><br>'+eve+'</td>';
}
else {
t+='<td valign="top" class="'+cD+'">'+x+'</td>';
}
if(((i)%7==0)&&(i<36))t+='</tr><tr>';
}
return t+='</tr></table></div>';
}

document.write('<center><table cellspacing="5" cellpadding="0" border="0" width="600"><tr><td align="center" colspan="3">'+buildCal(curmonth ,curyear, "main", "month", "daysofweek", "days", 1,770,504,1)+'</td></tr><tr><td align="left" width="102">'+buildCal(curmonth-1 ,curyear, "main", "month", "daysofweek", "days", 1,150,100,2)+'</td><td align="center"><table cellspacing="0" cellpadding="0"><tr><td align="center" bgcolor="black"><font color="white">News and Events</font></td></tr><tr><td align="center"><iframe src="events.html" name="calEvents" height="120" width="350">Sorry</iframe></td></tr></table></td><td align="right" width="102">'+buildCal(curmonth+1 ,curyear, "main", "month", "daysofweek", "days", 1,150,100,2)+'</td></tr></table>');

</script>

ddadmin
04-18-2007, 10:24 AM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.