/    Sign up×
Community /Pin to ProfileBookmark

Images to display on monday

I want to have a javascript which displays images on a page on on particular day, in this instance, Monday. The code below show’s what i’ve done to try and reach this but i’ve been unsuccesful in getting it right. The actual code works but in the 6th line specifying the getDay as you can see i’ve selected 1 for monday but it still displays the image on other days when i want it only on monday! ?

[B]day = new Date();
hours = day.getUTCHours()*60;
minutes = day.getUTCMinutes();
time = hours + minutes;

[COLOR=”Blue”]if (day.getDay()==1);[/COLOR]

if (time < 0) {time = time + 1440}
if (time > 1440) {time = time – 1440}

if(time<1140) { // 7:00 pm

document.write(”)

} else if(time<1260) { //9:00 pm

document.write(‘<img src=”on-air-now_10521.png” height=”21″ width=”105″ border=”0″>’)

} else if(time<1440) { // 12:00 am

document.write(”)

}[/B]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERDec 14.2007 — [code=php]
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Daily Image</title>

<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
var num=0;

// format: src, alt, text
imgArray = [

['../car.jpg', 'Cardiovascular', 'Sunday'],
['../gas.jpg', 'Gastroenterology','Monday'],
['../mus.jpg', 'Musculoskeletal', 'Tuesday'],
['../oph.jpg', 'Ophthalmic', 'Wednesday'],
['../oti.jpg', 'Otic', 'Thursday'],
['../res.jpg', 'Respiratory', 'Friday'],
['../dos.jpg', 'Drug Math', 'Saturday']
]

function slideshow(slide_num) {
document.getElementById('mypic').src=imgArray[slide_num][0];
document.getElementById('mypic').alt=imgArray[slide_num][1];

// document.getElementById("mylbl").childNodes[0].nodeValue=imgArray[slide_num][2];
document.getElementById('mylbl').innerHTML=imgArray[slide_num][2];
}

function slideshowUp() {
num++;
num = num % imgArray.length;
slideshow(num);
}

function slideshowBack() {
num--;
if (num < 0) { num = imgArray.length-1; }
num = num % imgArray.length;
slideshow(num);
}

function Initialize() {
var now = new Date();
num = now.getDay()
slideshow(num);
}
</SCRIPT>
</head>
<body onLoad="Initialize()">
<CENTER>

<IMG SRC="" id="mypic" alt="Blank" BORDER="0" HEIGHT="100" WIDTH="200">
<div id="mylbl" style="font-size:larger;"> Sunday </div>
<br>

<p>
<A HREF="#" onClick="slideshowBack(); return false;"> Back</A>
<A HREF="#" onClick="slideshowUp(); return false;"> Next</A>
</p>
</CENTER>
</body>
</html>
[/code]

Remove the functions "slideshowBack()" and "slideshowUp()"

and the <a href...> links since they don't appear to be needed.

Test link available at: http://www.nova.edu/optometry/pharmacy/old/DayShow.html

Good Luck!?
×

Success!

Help @stephenallden spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...