Enjoy an ad free experience by logging in. Not a member yet?
Register .
12-10-2012, 01:24 PM
PM User |
#1
New to the CF scene
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Display Message By day and time
Hello i got a problem i know how to make a display message by day code but i need one that for example te massage of the day will change at 10am not at midnight. I wan't to do be through monday to sunday. Thx
12-10-2012, 03:18 PM
PM User |
#2
Senior Coder
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,354
Thanks: 3
Thanked 458 Times in 445 Posts
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<div id="tst" ></div>
<script type="text/javascript">
<!--
var Messages=['Day 0','Day 1','Day 2','Day 3','Day 4','Day 5','Day 6'];
function Message(id,ary,hr){
var date=new Date(),obj=document.getElementById(id),hr=typeof(hr)=='number'&&hr>=0&&hr<=24?hr:24;
if (obj&&typeof(ary)=='object'&&ary.constructor==Array&&ary[0]){
obj.innerHTML=ary[date.getDay()+(date.getHours()>=hr?1:0)]||ary[0];
}
}
Message('tst',Messages,10);
//-->
</script>
</body>
</html>
Last edited by vwphillips; 12-10-2012 at 03:55 PM ..
12-10-2012, 03:49 PM
PM User |
#3
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Code:
<div id = "dailymessage"></div>
<script type = "text/javascript">
var messages = [];
messages[0]= "Sunday Message"
messages[1] = "Monday message";
messages[2] = "Tueday message"
messages[3] = "Wednesday message"
messages[4] = "Thursday message"
messages[5] = "Friday message";
messages[6] = "Saturday message";
var d = new Date(); // today
d = d.getTime() - 36000000; // subtract 10 hours
var nd = new Date(d);
var dy = nd.getDay();
document.getElementById("dailymessage").innerHTML = messages[dy];
</script>
"I have never taken any exercise except sleeping and resting." - Mark Twain, US humorist, novelist, short story author, & wit (1835 - 1910)
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
12-10-2012, 04:22 PM
PM User |
#4
New to the CF scene
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
How about if i wan't to input an image insted of a text im tyring <img></img> but it's not working
12-10-2012, 04:32 PM
PM User |
#5
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Code:
var please = false;
var thanks = false;
if (!please && !thanks) {
var interestLost = true;
var moreHelp = 0;
}
This is very easy - simply displaying an image - and you ought to be able to do it yourself. You have been given the code to make the daily change at 1000.
Why do you think that the word want has an apostrophe in it?
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 12-10-2012 at 04:49 PM ..
12-10-2012, 04:53 PM
PM User |
#6
Senior Coder
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,354
Thanks: 3
Thanked 458 Times in 445 Posts
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<img id="tst" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" alt="img">
<script type="text/javascript">
<!--
var Messages=['http://www.vicsjavascripts.org.uk/StdImages/1.gif','http://www.vicsjavascripts.org.uk/StdImages/2.gif','http://www.vicsjavascripts.org.uk/StdImages/3.gif','http://www.vicsjavascripts.org.uk/StdImages/4.gif','http://www.vicsjavascripts.org.uk/StdImages/5.gif','http://www.vicsjavascripts.org.uk/StdImages/6.gif','http://www.vicsjavascripts.org.uk/StdImages/7.gif'];
function Message(id,ary,hr){
var date=new Date(),obj=document.getElementById(id),hr=typeof(hr)=='number'&&hr>=0&&hr<=24?hr:24;
if (obj&&typeof(ary)=='object'&&ary.constructor==Array&&ary[0]){
obj.src=ary[date.getDay()+(date.getHours()>=hr?1:0)]||ary[0];
}
}
Message('tst',Messages,10);
//-->
</script>
</body>
</html>
12-10-2012, 05:02 PM
PM User |
#7
New to the CF scene
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks allot guys ye there shouldn't be a ( ' ) at (want) :P
Last edited by domitbg; 12-10-2012 at 05:14 PM ..
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 04:49 AM .
Advertisement
Log in to turn off these ads.