обратно броене

firefly
Турист
Турист
Posts: 274
Joined: Sat Jan 14, 2006 3:22 pm
Location: Gabrovo

обратно броене

Post by firefly » Mon Jan 16, 2006 8:16 pm

как мога да направя таймер с обратно броене, да показва времето оставащо до някакъв час на еди коя си дата?

User avatar
staf
Шаман
Шаман
Posts: 4254
Joined: Sun Sep 25, 2005 10:14 pm
Answers: 9

Post by staf » Mon Jan 16, 2006 8:30 pm

Срещал съм Javascript ако ми остане време по късно ще потърся

User avatar
bafitu
Много Редовен
Много Редовен
Posts: 1509
Joined: Mon Dec 12, 2005 9:12 am
Answers: 102
Location: Somewhere around nothing..

Post by bafitu » Mon Jan 16, 2006 8:39 pm

нещо такова ли ?!
http://web-tourist.net/project/bafitu/zz.html
това ще отброява времето оставащо до 2006/01/18
П.С. на английски е Countdown , потърси в гоогле за джаваскрипт има ги доста...

User avatar
fena
Web-tourist
Web-tourist
Posts: 2612
Joined: Sun Sep 25, 2005 10:14 pm
Answers: 15

Post by fena » Mon Jan 16, 2006 9:03 pm

еми можеше да му дадеш този който си посочил:

Code: Select all

<script type="text/javascript">
function countdown_clock&#40;year, month, day, hour, minute, format&#41;
         &#123;
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
         html_code = '<div id="countdown"></div>';
         
         document.write&#40;html_code&#41;;
         
         countdown&#40;year, month, day, hour, minute, format&#41;;                
         &#125;
         
function countdown&#40;year, month, day, hour, minute, format&#41;
         &#123;
         Today = new Date&#40;&#41;;
         Todays_Year = Today.getFullYear&#40;&#41; - 2000;
         Todays_Month = Today.getMonth&#40;&#41; + 1;                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = &#40;new Date&#40;Todays_Year, Todays_Month, Today.getDate&#40;&#41;, 
                                 Today.getHours&#40;&#41;, Today.getMinutes&#40;&#41;, Today.getSeconds&#40;&#41;&#41;&#41;.getTime&#40;&#41;;                                 
         Target_Date = &#40;new Date&#40;year, month, day, hour, minute, 00&#41;&#41;.getTime&#40;&#41;;                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round&#40;&#40;Target_Date - Todays_Date&#41; / 1000&#41;;
         
         if&#40;Time_Left < 0&#41;
            Time_Left = 0;
         
         switch&#40;format&#41;
               &#123;
               case 0&#58;
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1&#58;
                    //More datailed.
                    days = Math.floor&#40;Time_Left / &#40;60 * 60 * 24&#41;&#41;;
                    Time_Left %= &#40;60 * 60 * 24&#41;;
                    hours = Math.floor&#40;Time_Left / &#40;60 * 60&#41;&#41;;
                    Time_Left %= &#40;60 * 60&#41;;
                    minutes = Math.floor&#40;Time_Left / 60&#41;;
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if&#40;days == 1&#41; dps ='';
                    if&#40;hours == 1&#41; hps ='';
                    if&#40;minutes == 1&#41; mps ='';
                    if&#40;seconds == 1&#41; sps ='';
                    
                    document.all.countdown.innerHTML = days + ' day' + dps + ' ';
                    document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
                    document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and ';
                    document.all.countdown.innerHTML += seconds + ' second' + sps;
                    break;
               default&#58; 
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
               &#125;
               
         //Recursive call, keeps the clock ticking.
         setTimeout&#40;'countdown&#40;' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + '&#41;;', 1000&#41;;
         &#125;

</script>
<body>
<script type="text/javascript">countdown_clock&#40;06, 1, 18, 00, 00, 1&#41;;</script>
само че този май е да му задеш примерно 100 часа и той да брой...а ти мисля че търсиш да зададеш определена дата.


ето ти тук има доста: http://www.scriptgateway.com/scripts/ja ... nload.html

User avatar
bafitu
Много Редовен
Много Редовен
Posts: 1509
Joined: Mon Dec 12, 2005 9:12 am
Answers: 102
Location: Somewhere around nothing..

Post by bafitu » Mon Jan 16, 2006 9:20 pm

fena1 wrote: само че този май е да му задеш примерно 100 часа и той да брой...а ти мисля че търсиш да зададеш определена дата.
<script type="text/javascript">countdown_clock(06, 1, 18, 00, 00, 1);</script>
където : 06 - годината т.е. 2006
1 - месец т.е. Януари
18 - дата
00 - час
00 - минути
1 - секунди
т.е. до тая дата колко време остава това отброява.. може сам да си ги промени ..
така каго го гледам е писал до определен ЧАС на еди коя си ДАТА :wink:

firefly
Турист
Турист
Posts: 274
Joined: Sat Jan 14, 2006 3:22 pm
Location: Gabrovo

Post by firefly » Tue Jan 17, 2006 2:26 pm

мерси, аз едитнах един скрипт и стана така както го исках

User avatar
m0ralezz
Нов
Нов
Posts: 174
Joined: Fri Apr 28, 2006 9:33 am
Location: C:\Program Files
Contact:

Post by m0ralezz » Tue May 16, 2006 11:41 am

някой може ли да го едитне да го направи да отброява до световното,защото нещо не се справям със скрипта.. :?

User avatar
m0ralezz
Нов
Нов
Posts: 174
Joined: Fri Apr 28, 2006 9:33 am
Location: C:\Program Files
Contact:

Post by m0ralezz » Tue May 16, 2006 11:52 am

забравих да поясня...световното почва на 9 юни

User avatar
Access
Потребител
Потребител
Posts: 984
Joined: Wed May 10, 2006 12:40 pm
Location: Враца

Post by Access » Tue May 16, 2006 12:06 pm

с кое неможа да се справиш :)

Code: Select all

<script type="text/javascript">countdown_clock&#40;06, 1, 18, 00, 00, 1&#41;;</script>
това е последния ред от който зависи датата,часа и тн...

06 - си го оставяш така щото сме си 2006 година :)

на мястото на 1 слагаш месеца(юни)- демек 06 месец

на мястото на 18 слагаш датата -> 09

да речеме че почва в 18:30 първия мач :)

после първите две нули са ти часа ..... -> 18 часа

вторите две нули са ти минутите .... -> 30 мин

последната еденица са ти секундите :) може да я оставиш и така ...

кода става така:

Code: Select all

<script type="text/javascript"> 
function countdown_clock&#40;year, month, day, hour, minute, format&#41; 
         &#123; 
         //I chose a div as the container for the timer, but 
         //it can be an input tag inside a form, or anything 
         //who's displayed content can be changed through 
         //client-side scripting. 
         html_code = '<div id="countdown"></div>'; 
          
         document.write&#40;html_code&#41;; 
          
         countdown&#40;year, month, day, hour, minute, format&#41;;                
         &#125; 
          
function countdown&#40;year, month, day, hour, minute, format&#41; 
         &#123; 
         Today = new Date&#40;&#41;; 
         Todays_Year = Today.getFullYear&#40;&#41; - 2000; 
         Todays_Month = Today.getMonth&#40;&#41; + 1;                  
          
         //Convert both today's date and the target date into miliseconds.                            
         Todays_Date = &#40;new Date&#40;Todays_Year, Todays_Month, Today.getDate&#40;&#41;, 
                                 Today.getHours&#40;&#41;, Today.getMinutes&#40;&#41;, Today.getSeconds&#40;&#41;&#41;&#41;.getTime&#40;&#41;;                                  
         Target_Date = &#40;new Date&#40;year, month, day, hour, minute, 00&#41;&#41;.getTime&#40;&#41;;                  
          
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round&#40;&#40;Target_Date - Todays_Date&#41; / 1000&#41;; 
          
         if&#40;Time_Left < 0&#41; 
            Time_Left = 0; 
          
         switch&#40;format&#41; 
               &#123; 
               case 0&#58; 
                    //The simplest way to display the time left. 
                    document.all.countdown.innerHTML = Time_Left + ' seconds'; 
                    break; 
               case 1&#58; 
                    //More datailed. 
                    days = Math.floor&#40;Time_Left / &#40;60 * 60 * 24&#41;&#41;; 
                    Time_Left %= &#40;60 * 60 * 24&#41;; 
                    hours = Math.floor&#40;Time_Left / &#40;60 * 60&#41;&#41;; 
                    Time_Left %= &#40;60 * 60&#41;; 
                    minutes = Math.floor&#40;Time_Left / 60&#41;; 
                    Time_Left %= 60; 
                    seconds = Time_Left; 
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's'; 
                    //ps is short for plural suffix. 
                    if&#40;days == 1&#41; dps =''; 
                    if&#40;hours == 1&#41; hps =''; 
                    if&#40;minutes == 1&#41; mps =''; 
                    if&#40;seconds == 1&#41; sps =''; 
                    
                    document.all.countdown.innerHTML = days + ' day' + dps + ' '; 
                    document.all.countdown.innerHTML += hours + ' hour' + hps + ' '; 
                    document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and '; 
                    document.all.countdown.innerHTML += seconds + ' second' + sps; 
                    break; 
               default&#58; 
                    document.all.countdown.innerHTML = Time_Left + ' seconds'; 
               &#125; 
                
         //Recursive call, keeps the clock ticking. 
         setTimeout&#40;'countdown&#40;' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + '&#41;;', 1000&#41;; 
         &#125; 

</script> 
<body> 
<script type="text/javascript">countdown_clock&#40;06,06,09, 18,30, 00&#41;;</script>
Last edited by Access on Tue May 16, 2006 12:18 pm, edited 7 times in total.

User avatar
mute
Шаман
Шаман
Posts: 3127
Joined: Sun Sep 25, 2005 10:14 pm
Answers: 167
Location: between mind & heart
Contact:

Post by mute » Tue May 16, 2006 12:06 pm

знаем кога почна световното и ние го очакваме с нетарпение
иначе скрипта става

Code: Select all

<script type="text/javascript">
function countdown_clock&#40;06,06,09, 00,00, 00&#41;
         &#123;
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
         html_code = '<div id="countdown"></div>';
         
         document.write&#40;html_code&#41;;
         
         countdown&#40;year, month, day, hour, minute, format&#41;;               
         &#125;
         
function countdown&#40;year, month, day, hour, minute, format&#41;
         &#123;
         Today = new Date&#40;&#41;;
         Todays_Year = Today.getFullYear&#40;&#41; - 2000;
         Todays_Month = Today.getMonth&#40;&#41; + 1;                 
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = &#40;new Date&#40;Todays_Year, Todays_Month, Today.getDate&#40;&#41;,
                                 Today.getHours&#40;&#41;, Today.getMinutes&#40;&#41;, Today.getSeconds&#40;&#41;&#41;&#41;.getTime&#40;&#41;;                                 
         Target_Date = &#40;new Date&#40;year, month, day, hour, minute, 00&#41;&#41;.getTime&#40;&#41;;                 
         
         //Find their difference, and convert that into seconds.                 
         Time_Left = Math.round&#40;&#40;Target_Date - Todays_Date&#41; / 1000&#41;;
         
         if&#40;Time_Left < 0&#41;
            Time_Left = 0;
         
         switch&#40;format&#41;
               &#123;
               case 0&#58;
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1&#58;
                    //More datailed.
                    days = Math.floor&#40;Time_Left / &#40;60 * 60 * 24&#41;&#41;;
                    Time_Left %= &#40;60 * 60 * 24&#41;;
                    hours = Math.floor&#40;Time_Left / &#40;60 * 60&#41;&#41;;
                    Time_Left %= &#40;60 * 60&#41;;
                    minutes = Math.floor&#40;Time_Left / 60&#41;;
                    Time_Left %= 60;
                    seconds = Time_Left;
                   
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if&#40;days == 1&#41; dps ='';
                    if&#40;hours == 1&#41; hps ='';
                    if&#40;minutes == 1&#41; mps ='';
                    if&#40;seconds == 1&#41; sps ='';
                   
                    document.all.countdown.innerHTML = days + ' day' + dps + ' ';
                    document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
                    document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and ';
                    document.all.countdown.innerHTML += seconds + ' second' + sps;
                    break;
               default&#58;
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
               &#125;
               
         //Recursive call, keeps the clock ticking.
         setTimeout&#40;'countdown&#40;' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + '&#41;;', 1000&#41;;
         &#125;

</script>
<body>
<script type="text/javascript">countdown_clock&#40;06, 1, 18, 00, 00, 1&#41;;</script>
ако искаш и кажи точния час на първия мач :)

Post Reply