Results 1 to 3 of 3

Thread: Display Countdown Time Remaining

  1. #1
    Join Date
    Mar 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Post Display Countdown Time Remaining

    1) Script Title: Universal Countdown

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...lcountdown.htm

    3) Describe problem:
    Where do i change the script so that when days remaining = 0 it will only display hours, minutes, secs, If hours = 0, then it will only show minutes and secs, etc.

    launchdate.displaycountdown("days",

    Examples:
    0 days 23 Hours 54 Minutes 38 Seconds//
    23Hours 54Min 38Secs//Correct Display Would show this

    0Hours 54Min 38Secs//
    54Min 38Secs//Correct Display Would show this

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    add this code:
    Code:
    function noblank() {
    	if (this.timesup==false){//if target date/time not yet met
    		var displaystring="<span>";
    		arguments[0]=(arguments[0]==0 && arguments[0]=="0")?"":arguments[0]+" days ";
    		arguments[1]=(arguments[1]==0 && arguments[1]=="0" && arguments[0]=="")?"":arguments[1]+" hours ";
    		arguments[2]=(arguments[2]==0 && arguments[2]=="0" && arguments[1]=="")?"":arguments[2]+" minutes ";
    		arguments[3]=(arguments[3]==0 && arguments[3]=="0" && arguments[2]=="")?"":arguments[3]+" seconds";
    
    		 displaystring+=arguments[0]+arguments[1]+arguments[2]+arguments[3]+"</span> left until launch time";
    	} else { //else if target date/time met
    		var displaystring="Launch time!"
    	}
    	return displaystring
    }
    and when you use the displaycountdown() function use this: displaycountdown("days", noblank)
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. The Following User Says Thank You to Master_script_maker For This Useful Post:

    penster1 (03-05-2008)

  4. #3
    Join Date
    Aug 2004
    Posts
    9,918
    Thanks
    3
    Thanked 969 Times in 957 Posts
    Blog Entries
    15

    Default

    Inside your call back function used to display the output, you would simply do a simple test on arguments[0] (day field) for the value 0, and mold the output accordingly. So whereas before you may have this:

    Code:
    function formatresults(){
    if (this.timesup==false){//if target date/time not yet met
    var daysfield=(arguments[0]==0)? "" : arguments[0]+" days "
    var displaystring="<span style='background-color: #CFEAFE'>"+arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds</span> left until launch time"
    }
    else{ //else if target date/time met
    var displaystring="Launch time!"
    }
    return displaystring
    }
    You would change that slightly to:

    Code:
    function formatresults(){
    if (this.timesup==false){//if target date/time not yet met
    var daysfield=(arguments[0]==0)? "" : arguments[0]+" days "
    var displaystring="<span style='background-color: #CFEAFE'>"+daysfield+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds</span> left until launch time"
    }
    else{ //else if target date/time met
    var displaystring="Launch time!"
    }
    return displaystring
    }

  5. The Following User Says Thank You to ddadmin For This Useful Post:

    penster1 (03-05-2008)

Bookmarks

Posting Permissions

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