Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [javascript] błąd "is not defined"
sinbad
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 5.06.2009

Ostrzeżenie: (0%)
-----


Witam

Czy ktoś może ma pomysł skąd biorą się błedy javascript(debugger firebug) na tej stronie http://eb.home.pl/krys/hotelpl20110310/. Chodzi np o "OnLoad is not defined", Room capacity - pojawia się błąd "runStep is not defined" "numberPickerChangeValue is not defined". W większości gdzie jest wykorzystywany javascript występują błedy "is not defined" "is not founad". W kodzie są deklaracje tych zmiennych i funkcji.

Dzięki za wszelkie sugestie
Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 13)
krowal
post
Post #2





Grupa: Zarejestrowani
Postów: 561
Pomógł: 72
Dołączył: 15.11.2006

Ostrzeżenie: (0%)
-----


Masz błąd w OnLoad(), jest tam '//' - komentuje kawałek kodu a przy tym klamry zamykające definicję funkcji. Zmień tą funkcje na to:
[JAVASCRIPT] pobierz, plaintext
  1. function OnLoad() {
  2. Calendar.setup({
  3. inputField: 'stayLengthFromToFrom',
  4. ifFormat: '%Y-%m-%d',
  5. showsTime: false,
  6. button: 'stayLengthFromToFrom_button',
  7. singleClick: true,
  8. electric: false,
  9. step: 1
  10. });
  11. Calendar.setup({
  12. inputField: 'stayLengthFromToTo',
  13. ifFormat: '%Y-%m-%d',
  14. showsTime: false,
  15. button: 'stayLengthFromToTo_button',
  16. singleClick: true,
  17. electric: false,
  18. step: 1
  19. });
  20. var from = document.getElementById('stayLengthFromToFrom');
  21. xb.addEvent(from, 'change', function() {
  22. var to = document.getElementById('stayLengthFromToTo');
  23. var from = document.getElementById('stayLengthFromToFrom');
  24. var fromTime = getDateTime(from.value);
  25. var toTime = getDateTime(to.value);
  26. var fromDate = new Date(fromTime);
  27. var toDate = new Date(toTime); //to date cant be smaller than from date if (toDate < fromDate) { toDate.setTime(fromDate.getTime()); to.value = toDate.print('%Y-%m-%d'); } });var to = document.getElementById('stayLengthFromToTo'); var fn = function () { var to = document.getElementById('stayLengthFromToTo'); var from = document.getElementById('stayLengthFromToFrom'); var fromTime = getDateTime( from.value ); var toTime = getDateTime( to.value ); var fromDate = new Date( fromTime ); var toDate = new Date( toTime ); //to date must be greater than or equal to from date if (toDate < fromDate) { toDate.setTime(fromDate.getTime()); } to.value = toDate.print('%Y-%m-%d'); }; xb.addEvent(to,'change',fn);var from = document.getElementById('stayLengthFromToFrom'); xb.addEvent(from,'change',function(){ //date cant be earlier than minimal date var minDate = new Date( getDateTime( '2011-04-08' ) ); var to = document.getElementById('stayLengthFromToTo'); var from = document.getElementById('stayLengthFromToFrom'); var fromTime = getDateTime( from.value ); var toTime = getDateTime( to.value ); var fromDate = new Date( fromTime ); var toDate = new Date( toTime ); if (fromDate <= minDate) { fromDate.setTime(minDate.getTime()); from.value = fromDate.print('%Y-%m-%d'); alert('Arrival date mustn\'t be earlier than 2011-04-08'); } //to date must be at least one day forward if (fromDate >= toDate) { toDate.setTime(fromDate.getTime()); toDate.setDate(toDate.getDate()+1); to.value = toDate.print('%Y-%m-%d'); } //stay cant be longer then given number of days var testDate = new Date(toDate.getTime()); testDate.setDate(toDate.getDate() - 14); if (testDate > fromDate) { toDate.setTime(fromDate.getTime()); toDate.setDate(fromDate.getDate() + 14); to.value = toDate.print('%Y-%m-%d'); } countNights(from,to,document.getElementById('stayLengthNights')); });var to = document.getElementById('stayLengthFromToTo'); xb.addEvent(to,'change',function () { var to = document.getElementById('stayLengthFromToTo'); var from = document.getElementById('stayLengthFromToFrom'); var fromTime = getDateTime( from.value ); var toTime = getDateTime( to.value ); var fromDate = new Date( fromTime ); var toDate = new Date( toTime ); //dates cant be equal if (toDate.getTime() <= fromDate.getTime()) { toDate.setTime(fromDate.getTime()); toDate.setDate(fromDate.getDate() + 1); to.value = toDate.print('%Y-%m-%d'); } //stay cant be longer then given number of days var testDate = new Date(toDate.getTime()); testDate.setDate(toDate.getDate() - 14); if (testDate > fromDate) { toDate.setTime(fromDate.getTime()); toDate.setDate(fromDate.getDate() + 14); to.value = toDate.print('%Y-%m-%d'); } countNights(from,to,document.getElementById('stayLengthNights')); }); countNights(from,to,document.getElementById('stayLengthNights')); } function countNights(from,to,nights) { var dateF = from.value; var timeF = getDateTime( dateF ); var dateT = to.value; var timeT = getDateTime( dateT ); var night = parseInt( (timeT - timeF) / Date.DAY ); nights.value = night; } -->
  28. });
  29. }
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post
sinbad
post
Post #3





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 5.06.2009

Ostrzeżenie: (0%)
-----


Witam

Dzięki za odpowiedz, komentarze usunięte, a błąd nadal jest, jakieś inne sugestie

dzieki
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Instrukcje koncz średnikiem
config. Above
chyba powinno być
config.Above

analogicznie reszta
Go to the top of the page
+Quote Post
sinbad
post
Post #5





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 5.06.2009

Ostrzeżenie: (0%)
-----


sprawdziłem i nie ma żadnego wystąpienia "config. Above" - gdzie je widzisz ? średniki chyba wszędzie są :/
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Mi tam konsola FireBUga pokazuje na plik
wz_tooltip_stripped.js
i tam jest tak jak ci napisałem
Go to the top of the page
+Quote Post
sinbad
post
Post #7





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 5.06.2009

Ostrzeżenie: (0%)
-----


przerobione i nadal nic :/
Go to the top of the page
+Quote Post
nospor
post
Post #8





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Wywaliłem treść funkcji OnLoad i poszło. Można więc wnioskować, że to tam jest jakiś bobol.
Niestety ten kod to sieczka, zero enterów, zero wcięć - nie da sie tego analizować więc sobie darowałem.
Go to the top of the page
+Quote Post
sinbad
post
Post #9





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 5.06.2009

Ostrzeżenie: (0%)
-----


kod normalnie jest dobrze sformatowany, nie wiem dlaczego apache php czy smarty usuwa formatowanie
Go to the top of the page
+Quote Post
nospor
post
Post #10





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




To wklej tu ten kod który jest dobrze sformatowany.
Mowię o funkcji OnLoad
Go to the top of the page
+Quote Post
krowal
post
Post #11





Grupa: Zarejestrowani
Postów: 561
Pomógł: 72
Dołączył: 15.11.2006

Ostrzeżenie: (0%)
-----


@nospor: http://jsbeautifier.org/ pomocna rzecz (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post
nospor
post
Post #12





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Dzięki na przyszłość (IMG:style_emoticons/default/smile.gif)
Ale to autor powinien zadbać byśmy dostali coś co da się czytać a nie my mamy sami kombinować (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post
sinbad
post
Post #13





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 5.06.2009

Ostrzeżenie: (0%)
-----


Ok
[JAVASCRIPT] pobierz, plaintext
  1. function OnLoad() {
  2.  
  3. Calendar.setup({
  4. inputField: 'stayLengthFromToFrom',
  5. ifFormat: '%Y-%m-%d',
  6. showsTime: false,
  7. button: 'stayLengthFromToFrom_button',
  8. singleClick: true,
  9. electric: false,
  10. step: 1
  11. });
  12.  
  13. Calendar.setup({
  14. inputField: 'stayLengthFromToTo',
  15. ifFormat: '%Y-%m-%d',
  16. showsTime: false,
  17. button: 'stayLengthFromToTo_button',
  18. singleClick: true,
  19. electric: false,
  20. step: 1
  21. });
  22.  
  23. var from = document.getElementById('stayLengthFromToFrom');
  24. xb.addEvent(from,'change',function () {
  25. var to = document.getElementById('stayLengthFromToTo');
  26. var from = document.getElementById('stayLengthFromToFrom');
  27. var fromTime = getDateTime( from.value );
  28. var toTime = getDateTime( to.value );
  29. var fromDate = new Date( fromTime );
  30. var toDate = new Date( toTime );
  31. if (toDate < fromDate) {
  32. toDate.setTime(fromDate.getTime());
  33. to.value = toDate.print('%Y-%m-%d');
  34. }
  35. });
  36.  
  37. var to = document.getElementById('stayLengthFromToTo');
  38. var fn = function () {
  39. var to = document.getElementById('stayLengthFromToTo');
  40. var from = document.getElementById('stayLengthFromToFrom');
  41. var fromTime = getDateTime( from.value );
  42. var toTime = getDateTime( to.value );
  43. var fromDate = new Date( fromTime );
  44. var toDate = new Date( toTime );
  45. if (toDate < fromDate) {
  46. toDate.setTime(fromDate.getTime());
  47. }
  48. to.value = toDate.print('%Y-%m-%d');
  49. };
  50.  
  51. xb.addEvent(to,'change',fn);
  52. var from = document.getElementById('stayLengthFromToFrom');
  53. xb.addEvent(from,'change',function(){
  54. var minDate = new Date( getDateTime( '2011-04-08' ) );
  55. var to = document.getElementById('stayLengthFromToTo');
  56. var from = document.getElementById('stayLengthFromToFrom');
  57. var fromTime = getDateTime( from.value );
  58. var toTime = getDateTime( to.value );
  59. var fromDate = new Date( fromTime );
  60. var toDate = new Date( toTime );
  61. if (fromDate <= minDate) {
  62. fromDate.setTime(minDate.getTime());
  63. from.value = fromDate.print('%Y-%m-%d');
  64. alert('Arrival date mustn\'t be earlier than 2011-04-08');
  65. }
  66. if (fromDate >= toDate) {
  67. toDate.setTime(fromDate.getTime());
  68. toDate.setDate(toDate.getDate()+1);
  69. to.value = toDate.print('%Y-%m-%d');
  70. }
  71. var testDate = new Date(toDate.getTime());
  72. testDate.setDate(toDate.getDate() - 14);
  73. if (testDate > fromDate) {
  74. toDate.setTime(fromDate.getTime());
  75. toDate.setDate(fromDate.getDate() + 14);
  76. to.value = toDate.print('%Y-%m-%d');
  77. }
  78. countNights(from,to,document.getElementById('stayLengthNights'));
  79. });
  80.  
  81. var to = document.getElementById('stayLengthFromToTo');
  82. xb.addEvent(to,'change',function () {
  83. var to = document.getElementById('stayLengthFromToTo');
  84. var from = document.getElementById('stayLengthFromToFrom');
  85. var fromTime = getDateTime( from.value );
  86. var toTime = getDateTime( to.value );
  87. var fromDate = new Date( fromTime );
  88. var toDate = new Date( toTime );
  89. if (toDate.getTime() <= fromDate.getTime()) {
  90. toDate.setTime(fromDate.getTime());
  91. toDate.setDate(fromDate.getDate() + 1);
  92. to.value = toDate.print('%Y-%m-%d');
  93. }
  94. var testDate = new Date(toDate.getTime());
  95. testDate.setDate(toDate.getDate() - 14);
  96. if (testDate > fromDate) {
  97. toDate.setTime(fromDate.getTime());
  98. toDate.setDate(fromDate.getDate() + 14);
  99. to.value = toDate.print('%Y-%m-%d');
  100. }
  101. countNights(from,to,document.getElementById('stayLengthNights'));
  102. });
  103. countNights(from,to,document.getElementById('stayLengthNights'));
  104. }
  105. function countNights(from,to,nights) {
  106. var dateF = from.value;
  107. var timeF = getDateTime( dateF );
  108. var dateT = to.value;
  109. var timeT = getDateTime( dateT );
  110. var night = parseInt( (timeT - timeF) / Date.DAY );
  111. nights.value = night;
  112. }
[JAVASCRIPT] pobierz, plaintext



Najlepsze jest to że jak funkcja OnLoad() jest pusta, nadal jest ten sam błąd.

Ten post edytował sinbad 7.04.2011, 08:27:25
Go to the top of the page
+Quote Post
nospor
post
Post #14





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Powtórzyłem kroki co poprzednio i faktycznie przy pustej też się wali. I to jakieś dziwne błędy wychodzą. Ja się poddaje (IMG:style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 16:47