GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   javascript guru, what's problem here? (https://gfy.com/showthread.php?t=546667)

latinasojourn 12-01-2005 12:45 AM

javascript guru, what's problem here?
 
hi, i'm trying to rework a script written to show a different URL each day---it was originally written for 366 days, but i've shortened it to 13 days as a test---but does not show anything on the page.

i know nothing of javascript---can anyone tell me what's wrong? thanks!

hahahahahahahahahahahahahahahahahahahahahahahahaha hahahahahahahahahahahahahahahahahahahahahahaha


<HTML>

<head>
<title>Link Day</title>
</head>
<body>
<table align="center" border="0" width="300" height="100" cellspacing="0" cellpadding="0">
<tr align="center" valign="top">
<td align="center" valign="top">
<script>
/*
Enter the 366 urls and names below you wish to go to for each day of the year. DO NOT use commas
in the name or the script will not work.
*/
var daylinks=new Array()
daylinks[1]="http://www.cnn.com,CNN"
daylinks[2]="http://www.abcnews.com,ABCNews"
daylinks[3]="http://www.cnet.com,ABC"
daylinks[4]="http://www.geocities.com,Geocities"
daylinks[5]="http://www.lycos.com,Lycos"
daylinks[6]="http://www.infoseek.com,Infoseek"
daylinks[7]="http://www.hotbot.com,Hotbot"
daylinks[8]="http://www.tripod.com,Tripod"
daylinks[9]="http://www.wsabstract.com,Website Abstraction"
daylinks[10]="http://www.wired.com,Wired"
daylinks[11]="http://www.hotwired.com,Hotwired.com"
daylinks[12]="http://www.requestcode.com,Request Code"
daylinks[13]="http://www.dynamicdrive.com,Dynamic Drive"
var numdays=0
var daysa=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
var daysb=new Array(31,29,31,30,31,30,31,31,30,31,30,31) // for leap year
var tdate=new Date()
var tmonth=tdate.getMonth()
var tyear=tdate.getFullYear()
var tdays=tdate.getDate()
remain=tyear % 4
if(remain!=0) // if not leap year
{
for(x=0;x<tmonth;x++)
{
numdays=numdays+daysa[x]
}
}
else // if leap year
{
for(x=0;x<tmonth;x++)
{
numdays=numdays+daysb[x]
}
}
today=numdays+tdays
ranlink=daylinks[today].split(",") // separate the address and name
document.write("The featured link for today is: <a href='"+ranlink[0]+"' title='"+ranlink[1]+"' target='_new'>"+ranlink[1]+"</a>")
document.close()
</script>
</td>
</tr>
</table>
</body>
</html>

Nikita Khrushchev 12-01-2005 01:00 AM

Cou cant just use a script for a year. So use 366 days, or dont use it.

Do you want a random link script?

latinasojourn 12-01-2005 01:12 AM

Quote:

Originally Posted by Nikita Khrushchev
Cou cant just use a script for a year. So use 366 days, or dont use it.

Do you want a random link script?

no thanks, i've got random, i need something to hold a URL for 24hrs, and then change to next URL for 24hrs---not change at each refresh.

but i only want maybe 60 days.

the application is for a content rotation thing i'm doing in a member's area.

J.P. 12-01-2005 01:31 AM

try replacing the line that says:

Code:

today=numdays+tdays
with:

Code:

today=(numdays + tdays) % daylinks.length
and start the daylinks array with offset 0, like this:

Code:

daylinks[0]="http://www.cnn.com,CNN"
daylinks[1]="http://www.abcnews.com,ABCNews"
daylinks[2]="http://www.cnet.com,ABC"
daylinks[3]="http://www.geocities.com,Geocities"
daylinks[4]="http://www.lycos.com,Lycos"
daylinks[5]="http://www.infoseek.com,Infoseek"
...

this should solve your problem...

latinasojourn 12-01-2005 01:45 AM

Quote:

Originally Posted by J.P.
try replacing the line that says:

Code:

today=numdays+tdays
with:

Code:

today=(numdays + tdays) % daylinks.length
and start the daylinks array with offset 0, like this:

Code:

daylinks[0]="http://www.cnn.com,CNN"
daylinks[1]="http://www.abcnews.com,ABCNews"
daylinks[2]="http://www.cnet.com,ABC"
daylinks[3]="http://www.geocities.com,Geocities"
daylinks[4]="http://www.lycos.com,Lycos"
daylinks[5]="http://www.infoseek.com,Infoseek"
...

this should solve your problem...



great, it does resolve, and does not change on refresh, and i hope it will change again tomorrow.

you are a king!

THANKS SO MUCH!!!!!!!!

J.P. 12-02-2005 01:57 AM

I know I am :)


All times are GMT -7. The time now is 02:57 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123