calrockx
01-18-2003, 09:49 PM
hey, i've looked around, but i can't seem to find a certain script i'm looking for
i want a javascript that will write a certain message based on the day. like on chrsitmas it would say "merry christmas" and on new years "happy new years" something like that. it would only display a message on the days i set it for. not in a form box, something that i can put in a table cell.
anyone have this script or have a link to where i could find it? thanks!
calrockx
01-19-2003, 07:10 PM
hm, well i tried that, it didn't work...
i pasted that holiday array in the head section, the put the body part in the table cell where i want the text to display...i put in today's date a message to test it, didn't work. maybe i'm doing somthing wrong here?? help!
calrockx
01-19-2003, 09:51 PM
unfortunately, still didn't work
this is the section of the web page where i have the code...
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
Holidays = new Array(
new Array(1, 1, "Happy New Year"),
new Array(2, 14, "Happy Valentine's Day"),
new Array(3, 17, "Happy St. Patrick's Day"),
new Array(4, 1, "April Fool's"),
new Array(7, 4, "Happy Fourth of July"),
new Array(12, 25, "Merry Christmas")
);
function NAME_IT() {
window.open('contact.htm','EANITHING','toolbar=no,location=no, directories=no, status=yes, menubar=no, resizable=yes, copyhistory=no, scrollbars=no, width=300, height=300');
}
</script>
</HEAD>
<BODY TOPMARGIN=6 onLoad="MM_preloadImages('images/picicon2.gif','images/ramicon2.gif','images/linkicon2.gif')">
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
<TR>
<TD ROWSPAN=2 VALIGN=BOTTOM><A HREF="main.htm" TARGET="main"><B><I><FONT STYLE="font-family: ocrb, ocr a extended, impact, arial; font-size:16pt">www.mywebsite.com</FONT></I></B></A></TD>
<TD ALIGN=RIGHT>
<script>
<!-- // Begin
var curDate = new Date();
var mm = curDate.getMonth()+1;
var dd = curDate.getDate();
var j, len = Holidays.length;
for (j=0; j<len; j++) {
if (Holidays[j][0] == mm && Holidays[j][1] == dd) {
break;
}
}
if (j<len) {
document.write("<p>", Holidays[j][2], "</p>");
}
// End -->
</script>
</TD>
<TR>
<TD ALIGN=RIGHT VALIGN=BOTTOM>
<script>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()+1
if (month<10)
month="0"+month
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
document.write("<font STYLE='color:white; font-size:8pt'>"+month+"."+daym+"."+year+"</font>")</SCRIPT></TD>
</TR>
</TABLE>
sorry to make this so complicated, but the help is appreciated. any suggestions?