Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,529
    Thanks
    3
    Thanked 511 Times in 498 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 04:55 PM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,244
    Thanks
    203
    Thanked 2,555 Times in 2,533 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.

  • #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

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,244
    Thanks
    203
    Thanked 2,555 Times in 2,533 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?
    Last edited by Philip M; 12-10-2012 at 05:49 PM.

    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.

  • #6
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,529
    Thanks
    3
    Thanked 511 Times in 498 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>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #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 06:14 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •