Activity Stream
48,167 MEMBERS
6982 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member

    Default Help with Java Script

    I have the following java script for dispalying how long our gaming clan has been around. What it does is count downs the days until a sertain date, which is our Anniversary. What I would like to do is modify this code to update the year ("August 18, 2010") and restart the count and update the number of years or the Anniversary with out having to do it manually .

    <SCRIPT LANGUAGE = "JavaScript">
    var now = new Date();
    // set this value to the countdown date.
    var then = new Date("August 18, 2010");
    var gap = then.getTime() - now.getTime();
    gap = Math.floor(gap / (1000 * 60 * 60 * 24));
    document.write(gap);
    </SCRIPT>
    <!--your message here-->day's Until 10th Anniversary
    QRob001 Reviewed by QRob001 on . Help with Java Script I have the following java script for dispalying how long our gaming clan has been around. What it does is count downs the days until a sertain date, which is our Anniversary. What I would like to do is modify this code to update the year ("August 18, 2010") and restart the count and update the number of years or the Anniversary with out having to do it manually . <SCRIPT LANGUAGE = "JavaScript"> var now = new Date(); // set this value to the countdown date. var then = new Date("August 18, Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    No one has any idea how to help me with this?

  4.     
    #3
    Member
    check these links .. it might help
    Code: 
    http://www.hashemian.com/tools/javascript-countdown.html
    
    http://www.askdavetaylor.com/how_do_i_create_a_javascript_countdown_timer_on_my_web_page.html

  5.     
    #4
    Respected Member
    What do you mean manually? You want the date to change automatically to what?

  6.     
    #5
    Member
    I checked those 2 links im9ure but they were just creating a countdown timer like the one I have.

    Yes Lock Down, I want it to update to the next year and begin the countdown. Just as if I had updated the year my self.

    <SCRIPT LANGUAGE = "JavaScript">
    var now = new Date();
    // set this value to the countdown date.
    var then = new Date("August 18, 2010");
    var gap = then.getTime() - now.getTime();
    gap = Math.floor(gap / (1000 * 60 * 60 * 24));
    document.write(gap);
    </SCRIPT>
    <!--your message here-->day's Until 10th Anniversary

    I would like the year date "2010" to updat to "2011" when the count down reaches "0". Then I would like it to update the year anniversary "10th" to "11th".

  7.     
    #6
    Member
    Try this:
    Code: 
    <script type="text/javascript">
    var now=new Date()
    
    //Enter the Anniversary's MONTH (1-12) and DAY (1-31):
    var then=new Date(now.getFullYear(), 8, 18)
    
    var th = now.getFullYear() - 2000 // 11th anniversary on 2011
    
    var monthtext=new Array("Jan","Feb","Mar","April","May","June","July","Aug","Sep","Oct","Nov","Dec")
    then.setMonth(then.getMonth()-1) //change to 0-11 month format
    var showdate="("+monthtext[then.getMonth()]+" "+then.getDate()+")" //show date of Anniversary
    
    var one_day=1000*60*60*24
    var calculatediff=""
    
    calculatediff=Math.ceil((then.getTime()-now.getTime())/(one_day))
    if (calculatediff<0){
    var nextyearnow=new Date()
    nextyearnow.setFullYear(now.getFullYear()+1)
    calculatediff=Math.ceil((nextyearnow.getTime()-now.getTime())/(one_day)+calculatediff)
    th += 1
    }
    
    var beforeAnniversaryText="day's Until " + th + "th Anniversary"
    var onAnniversarytext="Today is Anniversary. Hooray :D"
    //Display message accordingly
    var pluraldayornot=(calculatediff==1)? "day" : "days"
    if (calculatediff>0)
        document.write("<b>"+calculatediff+" "+pluraldayornot+" "+beforeAnniversaryText+" "+showdate+"!</b>")
    else if (calculatediff==0)
        document.write("<b>"+onAnniversarytext+" "+showdate+"!</b>")
    
    </script>

  8.     
    #7
    Member
    Cool, thanks. I'll give it a try.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java stinks: Turn off your Java browser plugin
    By Loget in forum General Discussion
    Replies: 37
    Last Post: 5th Sep 2012, 07:40 AM
  2. Need help in JAVA
    By digimon in forum Web Development Area
    Replies: 10
    Last Post: 20th Jan 2012, 04:53 AM
  3. Need a java script programmer, imacros programmer
    By Vatra_Wolf in forum Traffic Market (Buy, Sell and Trade)
    Replies: 0
    Last Post: 21st Sep 2011, 03:01 PM
  4. Need Help HTML/Java Script Twitter/Countdown fixing
    By Andy~s in forum Web Development Area
    Replies: 0
    Last Post: 19th Dec 2010, 06:29 PM
  5. [Urgent] Help needed with "onClick=" Java script.
    By kushubham9 in forum Web Application/Script Support
    Replies: 0
    Last Post: 7th Mar 2010, 01:56 AM

Tags for this Thread

BE SOCIAL