can I add a hyperlink inside the text of eval()??

B

Billy

I want to make a calendar and add a hyperlink to the days inside the
calendar.

The source code is below:

<body>

<SCRIPT LANGUAGE="JavaScript">

var now = new Date();
var month_array = new
Array("january","february","march","April","May","June","July","August","September","October","November","December");
document.write("<form name=date_list><table border=0 cellspacing=1
cellpadding=2 bgcolor=#9999CC>");
document.write('<TR><td colspan="8" bgcolor="#9999CC">');
document.write("<font style=font-size:9pt;Color:White><b>Click the
date below to view your schedule:</b></FONT>");
document.write("</tr></td><tr><td align = right>");

document.write("<select name=month
onchange=change_month(this.options.selectedIndex)>");
for(i=0;i<month_array.length;i++)
{
if (now.getMonth() != i)
{document.write ("<option value="+i+">"+month_array);}
else
{document.write ("<option value="+i+" selected>"+month_array);}
}
document.write("</select>");

document.write ("<select name=year
onchange=change_year(this.options[this.options.selectedIndex])>");
for(i=1950;i<3000;i++)
{
if (now.getYear() != i)
{document.write("<option value="+i+">"+i);}
else
{document.write("<option value="+i+" selected>"+i);}
}
document.write("</select></td></tr><tr><td colspan=2><center>");
document.write("<table bgcolor=white border=0 cellspacing = 0
cellpading= 0 width=100%><tr bgcolor=#9999CC align=center>");
document.write("<td><font style=font-size:9pt;Color:White>Week in
IVE</FONT></td>");
document.write("<td><font
style=font-size:9pt;Color:White>Mon</FONT></td>");
document.write("<td><font
style=font-size:9pt;Color:White>Tue</FONT></td>");
document.write("<td><font
style=font-size:9pt;Color:White>Wed</FONT></td>");
document.write("<td><font
style=font-size:9pt;Color:White>Thu</FONT></td>");
document.write("<td><font
style=font-size:9pt;Color:White>Fri</FONT></td>");
document.write("<td><font
style=font-size:9pt;Color:White>Sat</FONT></td>");
document.write("<td ><font
style=font-size:9pt;red:White>Sun</FONT></td>");
document.write("</tr><tr>");
for(j=0;j<6;j++)
{
for(i=0;i<8;i++)
{
document.write("<td align=center id=d"+i+"r"+j+"></td>")
}
document.write("</tr>");
}
document.write("</table>");
document.write("</center></from></td></tr></table>");

var show_date = new Date();

function set_cal(show_date)
{
begin_day = new Date (show_date.getYear(),show_date.getMonth(),1);
begin_day_date = begin_day.getDay();
end_day = new Date (show_date.getYear(),show_date.getMonth()+1,1);
count_day = (end_day - begin_day)/1000/60/60/24;
input_table(begin_day_date,count_day);
}
set_cal(show_date);




function input_table(begin,count)
{
init();
j=0;
var logical = 21;

if (begin!=0){i=begin;}else{i=7}

colum_name = eval("d"+0+"r"+0);
colum_name.innerText = logical;

for (c=1;c<count+1;c++)
{
colum_name = eval("d"+i+"r"+j);

if ((now.getDate() == c)&&(show_date.getMonth() ==
now.getMonth())&&(show_date.getYear()
== now.getYear())) {colum_name.style.backgroundColor =
"blue";colum_name.style.color
= "white";};


<!-- document.write("<a href=viewTimetable.php?moduleID=TN3337>" + c+
"</a>");
but the hyper is outside the table, how to add hyper links of the
days inside the table
-->

colum_name.innerText = c; <!-- can I add hyperlink into the content
of eval or use other methods-->


i++;

if (i==8)
{
i=0;
colum_name = eval("d"+i+"r"+j);
colum_name.innerText = logical + begin;
j++;
i++;}
}
colum_name = eval("d"+0+"r"+j);
colum_name.innerText = logical + begin;
}



function changeurl(url)
{
document.write(url);
}

function init()
{
for(j=0;j<6;j++)
{
for(i=0;i<8;i++)
{
colum_name = eval("d"+i+"r"+j);
colum_name.innerText = " ";
colum_name.style.backgroundColor ="";
colum_name.style.color ="";

}
}
}

function change_month(sel_month)
{
show_date = new Date(show_date.getYear(),sel_month,1);
set_cal(show_date);
}
function change_year(sel_year)
{
sel_year = sel_year.value;
show_date = new Date(sel_year,show_date.getMonth(),1);
set_cal(show_date);
}
// End -->
</script>



</body>
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen
document.write("<font style=font-size:9pt;Color:White><b>Click the

Setting absolute sizes is bad practice; it discriminates against the
visually handicapped.

begin_day = new Date (show_date.getYear(),show_date.getMonth(),1);
begin_day_date = begin_day.getDay();
end_day = new Date (show_date.getYear(),show_date.getMonth()+1,1);
count_day = (end_day - begin_day)/1000/60/60/24;
input_table(begin_day_date,count_day);

That may be OK for HK, and for the rest of China (but Taiwan?); but it
may lead to error if executed elsewhere, since the length of the day is
not always 24 hours.

Maybe
end_day = new Date (show_date.getYear(),show_date.getMonth()+1, 0) ;
count_day = end_day.getDate() // *** ---^
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top