By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,077 Members | 2,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,077 IT Pros & Developers. It's quick & easy.

Calendar html page

P: n/a
I found the script below in internet and I want it to create a page with
links for each date changing according to date. For example:

For August 10, the link in calendar page should point to:
/cgi-bin/calendar_day.pl?userdir=calend&dept=boys&weekends= 1&datestamp=20040
810

For August 11, the link in calendar page should point to:
/cgi-bin/calendar_day.pl?userdir=calend&dept=boys&weekends= 1&datestamp=20040
811

So far I did not succeed, any hints please?

Thanks in advance.

Webminor
-------
<html>
<head>
<title>Takvim</title>
</head>
<body bgcolor="#FFFFFF" link="#008000" vlink="#800040" text="#000000">

<!-- begin calendar -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
title="javascript for Calendar";
// if you comment url and un-comment new_url a click on any day links to
edit-day
// otherwise a click on any day simply brings up the whole calendar
// note - there are two places where this choice is made , see later in the
script
// CHANGE HERE!
//url="<a
href=\"/cgi-bin/calendar.pl\?userdir=calend\&dept=boys\&weekends=1 \">";
new_url="<a
href=\"/cgi-bin/calendar_day.pl\?userdir=calend\&dept=boys\&weeken ds=1\&date
stamp=thisyear\"";
monthnames = new Array(
"January",
"Februrary",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"Decemeber");
var linkcount=0;
function addlink(month, day, href) {
var entry = new Array(3);
entry[0] = month;
entry[1] = day;
entry[2] = href;
this[linkcount++] = entry;
}
Array.prototype.addlink = addlink;
linkdays = new Array();
monthdays = new Array(12);
monthdays[0]=31;
monthdays[1]=28;
monthdays[2]=31;
monthdays[3]=30;
monthdays[4]=31;
monthdays[5]=30;
monthdays[6]=31;
monthdays[7]=31;
monthdays[8]=30;
monthdays[9]=31;
monthdays[10]=30;
monthdays[11]=31;
todayDate=new Date();
thisday=todayDate.getDay();
thismonth=todayDate.getMonth();
thisdate=todayDate.getDate();
thisyear=todayDate.getYear();
thisyear = thisyear % 100;
thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
if (((thisyear % 4 == 0)
&& !(thisyear % 100 == 0))
||(thisyear % 400 == 0)) monthdays[1]++;
startspaces=thisdate;
while (startspaces > 7) startspaces-=7;
startspaces = thisday - startspaces + 1;
if (startspaces < 0) startspaces+=7;
document.write("<table border=2 bgcolor=white ");
document.write("bordercolor=black>");

document.write("<tr><th colspan=7 bgcolor=yellow><font color=black><strong>"
+ title + "<br>"
+ monthnames[thismonth] + " " + thisdate + ", " + thisyear
+ "</strong></font></th></tr>");

document.write("<tr>");
document.write("<td align=center><b><font color=red>Su</font></b></td>");
document.write("<td align=center>M</td>");
document.write("<td align=center>Tu</td>");
document.write("<td align=center>W</td>");
document.write("<td align=center>Th</td>");
document.write("<td align=center>F</td>");
document.write("<td align=center><b><font color=red>Sa</font></b></td>");
document.write("</font></tr>");
document.write("<tr>");
for (s=0;s<startspaces;s++) {
document.write("<td></td>");
}
count=1;
while (count <= monthdays[thismonth]) {
for (b = startspaces;b<7;b++) {
if (count==thisdate) {
document.write("\n<td bgcolor=yellow>");
}
else {document.write("\n<td>");}
if (count==thisdate) {
document.write("<font size=+1><strong>");
}
if (count <= monthdays[thismonth]) {
// CHANGE HERE!
//document.write(url + count + "</a>");
document.write(new_url + thisyear + thismonth + count + "\">" +
count + "</a>");
}
else {
document.write(" ");
}
if (count==thisdate) {
document.write("</strong></font>");
}
document.write("</td>");
count++;
}
document.write("</tr>");
document.write("<tr>");
startspaces=0;
}
document.write("<tr><th colspan=7 bgcolor=yellow><strong>"
+ "Click on a day"
+ "</strong></font></th></tr>");
document.write("</table></p>");
// End -->
</SCRIPT>
<!-- end calendar -->

</body>
</html>
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JRS: In article <2n************@uni-berlin.de>, dated Tue, 10 Aug 2004
20:50:11, seen in news:comp.lang.javascript, Hitit <hi****@gmx.net>
posted :
I found the script below in internet and I want it to create a page with
links for each date changing according to date.
It's not a good script; its author did not have a good understanding of
the language.

When posting code to news, it is the POSTER's duty to ensure that his
system does not, by line-wrapping, break the code. Readers should not
have to do this. <FAQENTRY>
For example:

For August 10, the link in calendar page should point to:
/cgi-bin/calendar_day.pl?userdir=calend&dept=boys&weekends= 1&datestamp=20040
810

<SCRIPT LANGUAGE="JavaScript">
Deprecated. Use <script type="text/javascript">
new_url="<a
href=\"/cgi-bin/calendar_day.pl\?userdir=calend\&dept=boys\&weeken ds=1\&date
stamp=thisyear\""; ^^^^^^^^^^ ------------------- REMOVE 10 charsmonthnames = new Array(
"January",
"Februrary",
There are better ways of spelling some of those months, and
monthnames = ["January", "February", ... "December"]
is simpler.

Use Mo We Fr, not M W F.

IIRC, CSS can be used to centre the cell contents.

if (count <= monthdays[thismonth]) {
// CHANGE HERE!
//document.write(url + count + "</a>");
document.write(new_url + thisyear + thismonth + count + "\">" +
count + "</a>");


document.write(new_url +
((thisyear*100 + thismonth)*100 + count) +
"\">" + count + "</a>");
^^^^^ ---- What's that meant to do ?
Read the FAQ (see below), etc., and you will learn much.

There may be an error in the code for positioning the 1st of the month
in the right column; test for another month, or make the week run in ISO
form, Mon..Sun.

To satisfy my copy of the validator TIDY, "</a>" should be "<\/a>"
"</td>" should be "<\/td>" and other cases of </ in strings likewise.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.