PDA

View Full Version : best way to make calendar


qwertyuiop
03-05-2005, 11:21 PM
hi,
whats the best way to make a calendar (for a website)?

I think that using tables wuold be best. Wat are some other suggestions?

whackaxe
03-05-2005, 11:26 PM
i think tables are all you need. you could always use flash or java, but i seriously doubt they would be as good overall as a table

gsnedders
03-05-2005, 11:52 PM
Yeah - Calendars are tabular content, so use a table

eg: <table class="calendar">
<tr>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
<th>Sunday</th>
</tr>
<tr>
<td>&nbsp;</td>
<td class="event"><span class="num">1</span><ul><li>Testing: Valencia</li><li>Team Launch: Renault</li></ul></td>
<td class="event"><span class="num">2</span><ul><li>Testing: Valencia</li></ul></td>
<td class="event"><span class="num">3</span><ul><li>Testing: Valencia</li></ul></td>
<td class="event"><span class="num">4</span><ul><li>Testing: Valencia</li></ul></td>
<td><span class="num">5</span></td>
<td><span class="num">6</span></td>
</tr>
<tr>
<td class="event"><span class="num">7</span><ul><li>Testing: Silverstone</li><li>Testing: Jerez (Red Bull RB1 rollout)</li></ul></td>
<td class="event"><span class="num">8</span><ul><li>Testing: Jerez</li><li>Testing: Silverstone</li></ul></td>
<td class="event"><span class="num">9</span><ul><li>Testing: Jerez</li><li>Testing: Silverstone</li></ul></td>
<td class="event"><span class="num">10</span><ul><li>Testing: Jerez</li></ul></td>
<td class="event"><span class="num">11</span><ul><li>Testing: Jerez</li></ul></td>
<td class="event"><span class="num">12</span><ul><li>Testing: Jerez</li></ul></td>
<td class="event"><span class="num">13</span><ul><li>Testing: Jerez</li></ul></td>
</tr>
<tr>
<td><span class="num">14</span></td>
<td class="event"><span class="num">15</span><ul><li>Testing: Barcelona</li></ul></td>
<td class="event"><span class="num">16</span><ul><li>Testing: Barcelona</li></ul></td>
<td class="event"><span class="num">17</span><ul><li>Testing: Barcelona</li></ul></td>
<td class="event"><span class="num">18</span><ul><li>Testing: Barcelona</li></ul></td>
<td class="event"><span class="num">19</span><ul><li>Testing: Imola</li></ul></td>
<td class="event"><span class="num">20</span><ul><li>Testing: Imola</li></ul></td>
</tr>
<tr>
<td class="event"><span class="num">21</span><ul><li>Testing: Imola</li><li>Testing: Silverstone</li><li>Testing: Valencia</li></ul></td>
<td class="event"><span class="num">22</span><ul><li>Testing: Silverstone</li><li>Testing: Valencia</li></ul></td>
<td class="event"><span class="num">23</span><ul><li>Testing: Silverstone</li><li>Testing: Valencia</li></ul></td>
<td class="event"><span class="num">24</span><ul><li>Testing: Valencia</li></ul></td>
<td class="event"><span class="num">25</span><ul><li>Team Launch: Jordan</li><li>Team Launch: Ferrari</li></ul></td>
<td><span class="num">26</span></td>
<td><span class="num">27</span></td>
</tr>
<tr>
<td><span class="num">28</span></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

qwertyuiop
03-06-2005, 02:19 AM
does anyone know of a basic calendar layout (template?)?

just a basic calendar with numbers for each day (don't need any space in the table cell, im only gonna have numbers in the cell).

thanks

mlseim
03-06-2005, 05:19 AM
Put this part in the <head> portion of your page:
===========================================================

<script type="text/javascript" language="JavaScript">

<!-- Begin
var flg = 0;
var fs = 1;
var bg = "#666666";
M = new Array("January","February",
"March","April","May","June",
"July","August","September",
"October","November","December");
D = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
function getBgn() {
pdy = new Date(); // today
pday = pdy.getDate(); // get date
pmo = pdy.getMonth(); // present month
pyr = pdy.getYear(); // present year
if (pyr < 2000) // Y2K Fix
pyr = pyr + 1900; //
yr = yr1 = (pmo==0?pyr-1:pyr); // last month's year
mo = (pmo==0?11:pmo-1); // last month
bgn = new Date(M[mo]+" 1,"+yr1); // assign to date
document.write('<TABLE BORDER=0><TR><TD VALIGN=TOP>');
// Calendar(); // Send last month to screen
// document.write('</TD></tr><tr><TD VALIGN=TOP>');
yr = pyr; // present year
mo = pmo; // present month
bgn = new Date(M[mo]+" 1,"+yr); // assign to date
Calendar(); // Send this month to screen
document.write('</TD></tr><tr><TD VALIGN=TOP>');
yr = (pmo==11?pyr+1:pyr); // next month's year
mo = (pmo==11?0:pmo+1); // next month
bgn = new Date(M[mo]+" 1,"+yr); // assign to date
Calendar(); // Send next month to screen
document.write('</TD></TR></TABLE>'); // Finish up
}
function Calendar(){
dy = bgn.getDay();
yr = eval(yr);
d = "312831303130313130313031";
if (yr / 4 == Math.floor(yr / 4)) {
d = d.substring(0, 2) + "29" + d.substring(4, d.length);
}
pos = (mo * 2);
ld = eval(d.substring(pos, pos + 2));
document.write("<TABLE BORDER=0 cellpadding=1 cellspacing=1"
+ " BGCOLOR='" + bg
+ "'><TR><TD ALIGN=CENTER BGCOLOR=#EEEEEE COLSPAN=7>"
+ "<FONT FACE=arial SIZE=" + fs + ">" + M[mo] + " " + yr
+ "</FONT></TD></TR><TR><TR>");
for (var i = 0;i < 7;i ++) {
document.write("<TD ALIGN=CENTER BGCOLOR=#FFFFFF>"
+"<FONT SIZE=1>" + D[i] + "</FONT></TD>");
}
document.write("</TR><TR>");
ctr = 0;
for (var i = 0;i < 7; i++){
if (i < dy) {
document.write("<TD ALIGN=CENTER BGCOLOR=#FFFFFF>"
+"<FONT FACE=arial SIZE=" + fs + ">&nbsp;</FONT>"
+"</TD>");
}
else {
ctr++;
if (ctr == pday && mo == pmo){
document.write("<TD ALIGN=CENTER BGCOLOR=#00E384>"
+ "<FONT FACE=arial SIZE=" + fs + ">" + ctr + "</FONT>"
+ "</TD>");
}
else{
document.write("<TD ALIGN=CENTER BGCOLOR=#DDDDFF>"
+ "<FONT FACE=arial SIZE=" + fs + ">" + ctr + "</FONT>"
+ "</TD>");
}
}
}
document.write("</TR><TR>");
while (ctr < ld) {
for (var i = 0;i < 7; i++){
ctr++;
if (ctr > ld){
document.write("<TD ALIGN=CENTER BGCOLOR=#FFFFFF>"
+"<FONT FACE=arial SIZE=" + fs + ">"
+ "&nbsp;</FONT></TD>");
}
else
if (ctr == pday && mo == pmo){
document.write("<TD ALIGN=CENTER BGCOLOR=#00E384>"
+ "<FONT FACE=arial SIZE=" + fs + ">" + ctr + "&nbsp;</FONT>"
+ "</TD>");
}
else{
document.write("<TD ALIGN=CENTER BGCOLOR=#DDDDFF>"
+ "<FONT FACE=arial SIZE=" + fs + ">" + ctr + "&nbsp;</FONT>"
+ "</TD>");
}
}
document.write("</TR><TR>");
}
document.write("</TR></TABLE>");
}

// END -->
</SCRIPT>

=======================================================



Now, wherever you want the calendar to appear,
Put this part in your HTML <body>:
=======================================================

<script type="text/javascript" language="JavaScript">
<!-- Begin
getBgn();
// End -->
</SCRIPT>

=======================================================




.

qwertyuiop
03-06-2005, 06:19 AM
well, actually, i was looking for a site that generates clean tables for any month of any year that you chose.

i might use a php script that generates calendars, but i dont really want to go through all the trouble to find one, then set it up (the hard part!). cuz all i really want are calendars with certain days linked to other items on the site.

thanks for all the help.

Jalenack
03-06-2005, 07:54 PM
I know wordpress has a pretty nice calendar script...I haven't checked to see if its in the new version, but I know it was good in 1.2.2. I'd suggest downloading that and just using that specific calendar making function and tweaking it to your needs...HTH

qwertyuiop
03-06-2005, 09:13 PM
the wordpress thing is too complicated for me to setup.....

this is something i found, pretty much what i wanted:
http://www.phpkitchen.com/calendar.php

as of rite now, it shows februarey on the left and april on the right. i just want those really simple and small calendars. i guess i could do it manually.

qwertyuiop
03-06-2005, 11:13 PM
Ok.
I decided to manually do it. SO I began making the layout. i want it to look like this:
http://img49.exs.cx/img49/5893/calendar2pb.gif
(from this site (http://www.thespoke.net/MyBlog/Firedancer/MyBlog.aspx)).

I can't get the css to make the borders rite. the borders overlap and in some places, there are doubl borders.

heres my html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>

<title>calendar</title>

<style type="text/css">

.calendar {border: 1px solid #999; font: bold 9px Verdana, Arial, Helvetica, sans-serif; color: #7F7E71;}
.row td {height: 20px; width: 20px; border: 1px solid #999;}

.row td {
background-color: #FFFFFF;
text-align: center;
vertical-align: middle;
}
.dimmed {
color: #E4E4DD;
text-align: center;
vertical-align: middle;
}

</style>

</head>

<body>


<table border="0" cellpadding="0" cellspacing="0" width="200" class="calendar">

<thead class="caltitle">
<tr>
<th colspan="7"><a href="somepage.html">March 2005</a></th>
</tr>
</thead>

<!--
<tr class="daynames">
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
-->

<tr class="row">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>

<tr class="row">
<td>8</td>
<td><a href="linktosomewhere.html">9</a></td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
</tr>

<tr class="row">
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
</tr>

<tr class="row">
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>

<tr class="row">
<td>29</td>
<td>30</td>
<td>31</td>
<td class="dimmed">1</td>
<td class="dimmed">2</td>
<td class="dimmed">3</td>
<td class="dimmed">4</td>
</tr>

<tr class="calnav">
<td colspan="7">Prev | Next</td>
</tr>

</table>

</body>
</html>
you can copy the above code and paste it on this website (http://www.cris.com/~raydaly/hjdemo.shtml) and click the preview button to see my calendar.

whackaxe
03-07-2005, 11:36 PM
http://www.w3.org/TR/CSS21/tables.html#borders

it would appear tables don't treat borders the same

qwertyuiop
03-08-2005, 03:50 AM
ahh. you have to use border-collapse. thanks for all the help.