Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [jQuery] countdown nie odlicza dobrze //EDIT
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
john_doe
//EDIT: mój błąd dwa razy użyłem tej samej zmiennej count

poniżej przykładowy kod js. wszystko działa jak należy z wyjątkiem countdown ( linia 19 się zaczyna ten fragment kodu ), ma odliczać od 10. w tej postaci w div wpisuje mi się 1 i jedzie w dół. dlaczego?
na 100% coś mi się tu kłóci bo jak usunę wszystko i zostawię linijki od 19-26 ładnie odlicza od 10.
  1. $(document).ready(function () {
  2.  
  3. // set focus on input type text field
  4. $('#scanned_barcode').focus();
  5.  
  6. // close message box
  7. $('#closemessage').click( function () { $(this).parent('div').fadeOut('slow'); });
  8.  
  9. //auto hide information div
  10. setTimeout(function() {
  11. $('.information').fadeOut('slow');
  12. }, 12000);
  13.  
  14. // reload page every minute
  15. //setInterval("location.reload(true)", 30000);
  16. var address = "location.href='<?php echo base_url(); ?>production_statistic.screen.html'";
  17. setInterval(address, 240000);
  18.  
  19. // how many seconds to switch the screen
  20. var count = 10;
  21. id = setInterval(function(){
  22.  
  23. $('#countdown').html(count);
  24. count--;
  25.  
  26. }, 1000);
  27.  
  28. //progress bar animation
  29. var ex1running = false;
  30.  
  31. if(!ex1running)
  32. {
  33. ex1running = true;
  34. var $this = $(this);
  35. var count = 0;
  36. var inter = null;
  37.  
  38. function run()
  39. {
  40.  
  41. $this.find('.meter-value').css('width', count+"%");
  42. $this.find('.meter-text').text("Efektywność = " + count + "%");
  43.  
  44. if(count == parseInt( $('#get_value_progress').text() ))
  45. {
  46. clearInterval(inter);
  47. ex1running = false;
  48. }
  49.  
  50. count++;
  51.  
  52. }
  53.  
  54. inter = setInterval(run, 50);
  55.  
  56. }
  57.  
  58. });
rogoz
  1. var count = 10;
  2. id = setInterval(function(){
  3. .....
  4.  
  5. //progress bar animation
  6. var ex1running = false;
  7.  
  8. if(!ex1running)
  9. {
  10. ex1running = true;
  11. var $this = $(this);
  12. var count = 0;

Nie jestem pewien, ale rzuciło mi się w oczy
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.