/    Sign up×
Community /Pin to ProfileBookmark

Hep with events! Please.

I am trying to create a site that lists radio programs that are “on the air” based on the visitors computer. I’m using this right now, which works fine for weekday programs.

<SCRIPT LANGUAGE=”JAVASCRIPT”>
today = new Date()
if ((today.getHours() >14) && (today.getHours() <=18)){
document.write (“<IMG HEIGHT = 18 WIDTH = 75 SRC = ‘air.gif’>”)
}
</SCRIPT>

Problem is, there are different programs on during the weekends. The above method can only be used for the same daily schedule.
————————————-

I’m also using this method:

<script language=”javascript” type=”text/javascript”>

<!– Begin
document.write(“”)
day = new Date()
hr = day.getHours()
document.write(“”)
if (hr == 1)
document.write(“1AM”)
if (hr == 2)

etc…etc…

document.write(“”)
// End –>

</script>
————————————-

Same problem.

How can I incorporate the day into the equation?
I tried this, but it’s BOGUS!!!

<script language=”javascript” type=”text/javascript”>

<!– Begin
function DayOfWeek() {
var now = new Array(‘sunday’,’monday’,’tuesday’,’wednesday’,’thursday’,’friday’,’saturday’);
day = new Date()
var dow = now.getDay()
var hr = day.getHours()
document.write(“”)
if (hr == 17) && (dow == monday)
document.write(“MONDAY’S MESSAGE AT 5PM”)
document.write(“”)
// End –>

</script>
———————————–

I just want a script that will display who is live, on the air, for multiple radio stations, for any given time of the week and hour of the day.

Here is the page I am working on, so you can see the examples:
[url]http://mouthtick.com/test.php[/url]

Any help would be appreciated, Thanks!

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyNov 25.2008 — Change this part:
[CODE]var now = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
day = new Date()
var dow = now.getDay()
var hr = day.getHours()
document.write("")
if (hr == 17) && (dow == monday)[/CODE]

to this:
[CODE]var days = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
var now = new Date();
var dow = now.getDay();
var hr = now.getHours();
document.write("")
if (hr == 17) && (days[dow] == 'monday')[/CODE]
Copy linkTweet thisAlerts:
@smoothy321authorNov 25.2008 — Thanks, but it didn't work... I changed it as you said to this:

<script language="javascript" type="text/javascript">

<!-- Begin

function DayOfWeek() {

var days = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');

var now = new Date();

var dow = now.getDay();

var hr = now.getHours();

document.write("")

if (hr == 20) && (days[dow] == 'monday')

document.write("MONDAY'S MESSAGE AT 8PM")

document.write("")

// End -->

</script>

Made the hour 20 because it's 8pm here....

Just came up blank though...

Maybe javascript wont work for this?
Copy linkTweet thisAlerts:
@MrNobodyNov 25.2008 — Put in an alert and see what you're getting:
[CODE]alert('hr='+hr+',dow='+dow+',days[dow]='+days[dow]);
if (hr == 20) && (days[dow] == 'monday')[/CODE]
Copy linkTweet thisAlerts:
@smoothy321authorNov 25.2008 — I tried the alert code in various locations... nothing came up. Could you post the full code so that I could try that? Thanks
Copy linkTweet thisAlerts:
@MrNobodyNov 25.2008 — Did you fix the first error I pointed out?
Copy linkTweet thisAlerts:
@smoothy321authorNov 25.2008 — This is what I entered on the page:

<script language="javascript" type="text/javascript">

<!-- Begin

function DayOfWeek() {

var days = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');

var now = new Date();

var dow = now.getDay();

var hr = now.getHours();

document.write("")

if (hr == 21) && (days[dow] == 'monday')

alert('hr='+hr+',dow='+dow+',days[dow]='+days[dow]);

if (hr == 20) && (days[dow] == 'monday')

document.write("MONDAY'S MESSAGE AT 9PM")

document.write("")

// End -->

</script>

Which, includes the error you pointed out I believe...
Copy linkTweet thisAlerts:
@smoothy321authorNov 25.2008 — Damn, power in the house went out as I was typing new message.... disregard last one. I had this:

<script language="javascript" type="text/javascript">

<!-- Begin

function DayOfWeek() {

var days = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');

var now = new Date();

var dow = now.getDay();

var hr = now.getHours();

document.write("")

if (hr == 21) && (days[dow] == 'monday')

alert('hr='+hr+',dow='+dow+',days[dow]='+days[dow]);

if (hr == 21) && (days[dow] == 'monday')

document.write("MONDAY'S MESSAGE AT 9PM")

document.write("")

// End -->

</script>

For a 9 o'clock time...

Still blank
Copy linkTweet thisAlerts:
@MrNobodyNov 25.2008 — Your browser is reporting errors and you're not looking at them.
Copy linkTweet thisAlerts:
@smoothy321authorNov 25.2008 — I took the code out:

<script language="javascript" type="text/javascript">

<!-- Begin

function DayOfWeek() {

var days = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');

var now = new Date();

var dow = now.getDay();

var hr = now.getHours();

document.write("")

if (hr == 21) && (days[dow] == 'monday')

alert('hr='+hr+',dow='+dow+',days[dow]='+days[dow]);

if (hr == 21) && (days[dow] == 'monday')

document.write("MONDAY'S MESSAGE AT 9PM")

document.write("")

// End -->

</script>


And the errors went away....

The error is in the above code...
Copy linkTweet thisAlerts:
@MrNobodyNov 25.2008 — So list the errors. One is that your function is not terminated correctly.
×

Success!

Help @smoothy321 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...