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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tip of the Day code - for 365 days instead of just 31

    I would like to use the "Tip of the Day" code on my web page, however, the code only allows 31 quotes/tips to be included, based on the date of the month (1 to 31). Is there any way to alter this code so that I can include 365 quotes (1 for each day of the year)? (PS. I have no coding skills to speak of)

    See original code below:
    ----------------------------
    <table border="0" width="100%" bgcolor="#E8E8E8" cellspacing="0" cellpadding="0">
    <tr><td width="100%">

    <script>
    <!--

    /*
    Tip of the day script
    By JavaScript Kit (http://javascriptkit.com)
    Over 200+ free scripts here!
    */

    var today_obj=new Date()
    var today_date=today_obj.getDate()

    var tips=new Array()
    //Configure the below variable to contain the "header" of the tip
    var tiptitle='<img src="../../tip.gif"> <b>JavaScript Tip of the day</b><br>'

    //Configure the below array to hold the 31 possible tips of the month
    tips[1]='Tip 1 goes here'
    tips[2]='Tip 2 goes here'
    tips[3]='Tip 3 goes here'
    tips[4]='Tip 4 goes here'
    tips[5]='Tip 5 goes here'
    tips[6]='Tip 6 goes here'
    tips[7]='Tip 7 goes here'
    tips[8]='Tip 8 goes here'
    tips[9]='Tip 9 goes here'
    tips[10]='Tip 10 goes here'
    tips[11]='Tip 11 goes here'
    tips[12]='Tip 12 goes here'
    tips[13]='Tip 13 goes here'
    tips[14]='Tip 14 goes here'
    tips[15]='Tip 15 goes here'
    tips[16]='Tip 16 goes here'
    tips[17]='Tip 17 goes here'
    tips[18]='Tip 18 goes here'
    tips[19]='Tip 19 goes here'
    tips[20]='Tip 20 goes here'
    tips[21]='Tip 21 goes here'
    tips[22]='Tip 22 goes here'
    tips[23]='Tip 23 goes here'
    tips[24]='Tip 24 goes here'
    tips[25]='Tip 25 goes here'
    tips[26]='Tip 26 goes here'
    tips[27]='Tip 27 goes here'
    tips[28]='Tip 28 goes here'
    tips[29]='Tip 29 goes here'
    tips[30]='Tip 30 goes here'
    tips[31]='Tip 31 goes here'

    document.write(tiptitle)
    document.write(tips[today_date])

    //-->
    </script>

    </td></tr></table>
    <p align="center"><font face="arial" size="-2">This free script provided by</font><br>
    <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
    Kit</a></font></p>

    ------------------------------------

  • #2
    JUD
    JUD is offline
    New Coder
    Join Date
    Jul 2005
    Location
    I'm right here
    Posts
    92
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    <script>
    <!--
    
    /*
    Tip of the day script
    By JavaScript Kit (http://javascriptkit.com)
    Over 200+ free scripts here!
    */
    
    var today_obj=new Date()
    
    with(today_obj){
    	var year = getFullYear()
    	var month = getMonth()
    	var date = getDate()
    }
    
    var day_of_year = (Date.UTC(year, month, date) - Date.UTC(year, 0, 0)) / 86400000
    
    var tips=new Array()
    //Configure the below variable to contain the "header" of the tip
    var tiptitle='<img src="../../tip.gif"> <b>JavaScript Tip of the day</b><br>'
    
    //Configure the below array to hold the 365 possible tips of the year
    tips[1]='Tip 1 goes here'
    tips[2]='Tip 2 goes here'
    tips[3]='Tip 3 goes here'
    tips[4]='Tip 4 goes here'
    tips[5]='Tip 5 goes here'
    tips[6]='Tip 6 goes here'
    tips[7]='Tip 7 goes here'
    tips[8]='Tip 8 goes here'
    tips[9]='Tip 9 goes here'
    tips[10]='Tip 10 goes here'
    tips[11]='Tip 11 goes here'
    tips[12]='Tip 12 goes here'
    tips[13]='Tip 13 goes here'
    tips[14]='Tip 14 goes here'
    tips[15]='Tip 15 goes here'
    tips[16]='Tip 16 goes here'
    tips[17]='Tip 17 goes here'
    tips[18]='Tip 18 goes here'
    tips[19]='Tip 19 goes here'
    tips[20]='Tip 20 goes here'
    tips[21]='Tip 21 goes here'
    tips[22]='Tip 22 goes here'
    tips[23]='Tip 23 goes here'
    tips[24]='Tip 24 goes here'
    tips[25]='Tip 25 goes here'
    tips[26]='Tip 26 goes here'
    tips[27]='Tip 27 goes here'
    tips[28]='Tip 28 goes here'
    tips[29]='Tip 29 goes here'
    tips[30]='Tip 30 goes here'
    tips[31]='Tip 31 goes here'
    // ...
    tips[365]='Tip 365 goes here'
    
    document.write(tiptitle)
    document.write(tips[day_of_year])
    
    //-->
    </script>

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks so much - really appreciate your help...
    Pesi

  • #4
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Am I missing a bit of code?

    I am psyched that this code is here but I can't get it to work! Is there a bit of script code that needs to go into the head of the page? I am new to this kind of code and I am lost.

    Thanks for your help!

  • #5
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Not entirly sure, but i think it all needs to go in the head

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts
    sorry ignore that instructions here : http://www.javascriptkit.com/script/...2/tipday.shtml

  • #7
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,131
    Thanks
    2
    Thanked 328 Times in 320 Posts
    If you are using the 365 day version (and perhaps even the 31 day version), doing this using javascript requires sending all the data to the browser every time the page is served. This will result in a slowly loading page.

    Doing a tip of the day is best handled using a server side scripting language, where you would only send the content for that day to the browser.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #8
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tip of the day for 365 days

    Is this code in url http://codingforums.com/javascript-programming/94489-tip-day-code-365-days-instead-just-31-a.html is still effective? but when I copy & paste the code into a simple html file and run, it displays "undefined". I've put this code into the head section as well as into the server and tried as advised, but failed in FF, IE & google crome with all latest versions.

    I shall be much thankful, if there is an alternative way to modify this 365 tip of the day code to suit the current trends of the browsers as I value this code very much.

    Thanking you !!!


  •  

    Posting Permissions

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