If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

I think I am still doing something incorrectly (nothing is showing up).

Code:

<script type = "text/javascript">
Date.prototype.getDOY = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((this - onejan) / 86400000);
}
var today = new Date();
var DOY = today.getDOY(); // DOY is day of year 1-365 or 366 in leap year
DOY = (parseInt(DOY%43))+1; // 5 is number of tips currently specified in the TOD array - you can have as many as you want up to 366
var TOD = new Array(366);
TOD[1] = "Lock your door, even when you intend to return home shortly or even if you are just going down the hall. It takes a thief ten seconds or less to enter an open room and steal your property";
TOD[2] = "Lock or secure doors and windows when you are alone or asleep";
TOD[3] = "Keep emergency numbers by your phone";
TOD[4] = "Do not leave messages on your door indicating that you are away and when
you will return";
TOD[5] = "Do not let strangers enter your home";
TOD[6] = "Do not prop open outer doors";
TOD[7] = "If someone asks to use your phone for an emergency call, offer to telephone
for them instead of allowing them access";
TOD[8] = "Do not put your address on your key ring";
TOD[9] = "Know your neighbors";
TOD[10] = "Do not leave keys in hiding places. Thieves will find them. Carry your
keys or make sure that anyone who truly needs them has their own copy";
TOD[11] = "Call 911 to report suspicious persons or activity in or around your neighborhood";
TOD[12] = "Open a savings or checking account instead of keeping money in your room";
TOD[13] = "Keep automatic teller machine cards in a safe place, keep your PIN number
secret. When possible, only use ATMs during the day";
TOD[14] = "Instead of carrying large sums of cash use a charge card. Some charge cards
insure property purchased with those cards against loss, theft or damage";
TOD[15] = "If you find yourself in immediate danger, call 911; try to stay calm and
get away at the first opportunity";
TOD[16] = "Avoid walking alone at night unless absolutely necessary";
TOD[17] = "Keep to well lit commonly traveled routes";
TOD[18] = "Avoid shortcuts and dark, isolated areas";
TOD[19] = "Walk purposefully, know where you are going, and project a no-nonsense
image";
TOD[20] = "Avoid potentially dangerous situations";
TOD[21] = "If you feel threatened, cross the street, locate an emergency phone, or
enter a store or place of business even if you have just left it";
TOD[22] = " Have your door keys ready; carry them in your pockets, not buried in a
purse";
TOD[23] = "Always lock your car. (one in five stolen cars was left with keys in the
ignition.)";
TOD[24] = "Lock bikes to immovable objects or bike racks with hardened alloy locks
and chains or U-shaped lock";
TOD[25] = "Do not leave tempting valuables or property visible inside the car. Lock
these items in the trunk";
TOD[26] = "Lock mopeds as you would bikes";
TOD[27] = "Look into your car before getting in. Lock doors and roll up windows once
inside for protection";
TOD[28] = "Never pick up hitchhikers";
TOD[29] = "Carry change for emergency calls. 911 is a free call";
TOD[30] = "Drive to a police or fire station or open place of business if you feel
you are being followed";
TOD[31] = "Do not stop to help occupants of stopped or disabled vehicles";
TOD[32] = "Continue driving to the nearest phone and call assistance for them";
TOD[33] = "Raise the hood, and then lock yourself into your car if it breaks down.
If someone stops and offers you help, remain in your car and ask them to
phone for help. Do not worry about seeming rude";
TOD[34] = "Travel with a friend or in a group";
TOD[35] = "Be alert and aware of your surroundings";
TOD[36] = "Avoid dark, vacant or deserted areas; use well-lit, well-traveled routes";
TOD[37] = "Dress in clothes and shoes which will not hamper movemen";
TOD[38] = "Move away from the potential threat if possible";
TOD[39] = "Join any group of people nearby; cross the street and increase your pace";
TOD[41] = "If a threatening situation is imminent, and people are close by to help,
yell, scream or make a commotion in any way you can to get their attention";
TOD[42] = "Go to an open business";
TOD[43] = "Call 911 from a safe location";
// and so on up to TOD[366] (to allow for leap year)
var weekDays = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var dd = today.getDate();
var dy = today.getDay();
var mm = today.getMonth();
var yy = today.getFullYear();
var daySuffix = 'th';
if(dd != 11 && dd != 12 && dd != 13) {ddx = dd % 10}
else {ddx = dd}
if (ddx == 1) { daySuffix = 'st' }
if (ddx == 2) { daySuffix = 'nd' }
if (ddx == 3) { daySuffix = 'rd' }
var tipOfDay = "Tip of the day for " + weekDays[dy] + " " + dd + daySuffix + " " + months[mm] + " " + yy + ":- &nbsp&nbsp " + TOD[DOY]
document.write(tipOfDay);
</script>

See anything obvious?
I put DOY%43 because there is currently 43 tips )TOD) in the array.

Also, if I wanted to place the data in a Table (for formatting), how would I call the script from an external javascript file?