PDA

View Full Version : To all pro's - How to customize this script



pirilti
03-14-2008, 02:59 PM
1) Script Title: Dynamic Countdown Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm

3) Describe problem: Customize this script so it can do the following things:

1. The script to start at 09:00:00 and countdown to 18:00:00 every Monday to Friday and Sunday.

2. On saturdays it should not show at all


I'll really appriciate it if somebody would help me customize it. I'm not that gould at scripting and have tried to make it work for over 2 days with no luck at all...:(

ddadmin
03-14-2008, 11:04 PM
The code would look something like the below. The parts in red are new from your normal code:


<script type="text/javascript">

var now=new Date()
var end=new Date()
end.setHours(18)
end.setMinutes(0)
end.setSeconds(0)

if (now.getDay()!=6 && now.getHours()>=9 && now.getHours()<18){ //if not Sat and current time is between 6 and 18
var futuredate=new cdtime("countdowncontainer", end)
futuredate.displaycountdown("days", formatresults)
}

</script>

pirilti
03-16-2008, 02:10 PM
It's working now...

You are the best...:D

pirilti
03-16-2008, 03:16 PM
Is this possible.....???

I want this script to change the first argument which in this case is hours.


At this moment it shows: 1 hours 10 min. 3 sec. left

Can I make this show like: 1 hour 10 min. 3 sec. left

And also still show hours when it's equal to 2 or more...

Thanks in advance

ddadmin
03-16-2008, 11:43 PM
In your formatresults() function, you'd simply add a little test for "1" hour in the second argument, something like:


function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var hoursfield=arguments[1]+(arguments[1]==1? " hour " : " hours ")
var displaystring=arguments[0]+" days "+hoursfield+arguments[2]+" minutes "+arguments[3]+" seconds left until March 23, 2009 18:25:00"
}
else{ //else if target date/time met
var displaystring="Future date is here!"
}
return displaystring
}

pirilti
03-17-2008, 10:45 AM
Thank you so much... This is just amazing...:D