Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript][PHP] wyświetlenie skryptu JS w php
Ulysess
post
Post #1





Grupa: Zarejestrowani
Postów: 695
Pomógł: 65
Dołączył: 27.07.2009
Skąd: Y

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


witam pewnie to dla was śmieszne i banalne ale nie jestem w stanie wyświetlić tego w składni php (IMG:style_emoticons/default/sad.gif)

mam skrypt który wyświetla txt po okreslonym czasie, niestety gdy go daje w echo to albo personal error mi wyskakuje albo jak 'niby' poprawnie działa to nie wyświetla txt (tak jakby tego JS w kodzie nie było)

skrypt wygląda następująco:

  1.  
  2. <script language="JavaScript">
  3. var tura="";
  4. var nrlog=0;
  5.  
  6. var tura0="";
  7. var tura1;
  8. tura1=tura0+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura1;",1000);
  9. var tura2;
  10. tura2=tura1+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura2;",2000);
  11. var tura3;
  12. tura3=tura2+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura3;",3000);
  13. var tura4;
  14. tura4=tura3+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura4;",4000);
  15. var tura5;
  16. tura5=tura4+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura5;",5000);


w php próbuje dać tak:

  1. echo 'var tura4;
  2. tura4=tura3+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById(\'log\').innerHTML=tura4;",4000);';


i tak jak już mówiłem nie działa (IMG:style_emoticons/default/sad.gif) z góry dziękuje za pomoc
Go to the top of the page
+Quote Post
varez
post
Post #2





Grupa: Zarejestrowani
Postów: 275
Pomógł: 32
Dołączył: 17.06.2007

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


"personal error" rozumiem, że to błąd parsowania? (IMG:style_emoticons/default/biggrin.gif)

a nie możesz po prostu zamknąć php, wrzucić kod i otworzyć znów php?

  1. <?php
  2. if (666==666) {
  3. // jakies operacje
  4. }
  5. // reszta kodu, jakieś echo
  6. ?>
  7. <script language="JavaScript">
  8. var tura="";
  9. var nrlog=0;
  10.  
  11. var tura0="";
  12. var tura1;
  13. tura1=tura0+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura1;",1000);
  14. var tura2;
  15. tura2=tura1+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura2;",2000);
  16. var tura3;
  17. tura3=tura2+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura3;",3000);
  18. var tura4;
  19. tura4=tura3+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura4;",4000);
  20. var tura5;
  21. tura5=tura4+"<font size=2>tekst do wyświetlenia<br>"; setTimeout("document.getElementById('log').innerHTML=tura5;",5000);
  22. </script>
  23. <?php
  24. // reszta kodu,
  25. ?>
  26. <div id="log"> 666 </div>


edit:
mi działa perfekcyjnie powyższy kod (IMG:style_emoticons/default/smile.gif)

Ten post edytował varez 11.05.2010, 15:20:41
Go to the top of the page
+Quote Post
Ulysess
post
Post #3





Grupa: Zarejestrowani
Postów: 695
Pomógł: 65
Dołączył: 27.07.2009
Skąd: Y

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


ahh zapomniałem dodać na końcu diva.. dzięki (IMG:style_emoticons/default/smile.gif) , Twoje rozwiązanie nic mi nie daje ponieważ potrzebuje wyświetlić dane które są w pętli (IMG:style_emoticons/default/smile.gif)

mniej więcej miało by to tak wyglądać:

  1.  
  2. <?php
  3.  
  4. echo '<script language="JavaScript">
  5. var tura="";
  6. var nrlog=0;
  7.  
  8. var tura0="";';
  9.  
  10. for ($l_r = 1; $l_r <= 3 ;$l_r++)
  11. {
  12. echo 'var tura1;
  13. tura1=tura0+"<font size=2>tekst '.$l_r.'<br>"; setTimeout("document.getElementById('log').innerHTML=tura1;",2000);';
  14. }
  15.  
  16. echo '<div id="log"> 666 </div>';
  17. echo '</script>';
  18.  
  19. ?>
  20.  



niestety to nie działa :/

Ten post edytował Ulysess 11.05.2010, 16:06:46
Go to the top of the page
+Quote Post
kamillo121
post
Post #4





Grupa: Zarejestrowani
Postów: 127
Pomógł: 6
Dołączył: 26.07.2009

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


Cytat(Ulysess @ 11.05.2010, 17:02:09 ) *
ahh zapomniałem dodać na końcu diva.. dzięki (IMG:style_emoticons/default/smile.gif) , Twoje rozwiązanie nic mi nie daje ponieważ potrzebuje wyświetlić dane które są w pętli (IMG:style_emoticons/default/smile.gif)

mniej więcej miało by to tak wyglądać:

  1.  
  2. <?php
  3.  
  4. echo '<script language="JavaScript">
  5. var tura="";
  6. var nrlog=0;
  7.  
  8. var tura0="";';
  9.  
  10. for ($l_r = 1; $l_r <= 3 ;$l_r++)
  11. {
  12. echo 'var tura1;
  13. tura1=tura0+"<font size=2>tekst '.$l_r.'<br>"; setTimeout("document.getElementById('log').innerHTML=tura1;",2000);';
  14. }
  15.  
  16. echo '<div id="log"> 666 </div>';
  17. echo '</script>';
  18.  
  19. ?>
  20.  



niestety to nie działa :/


dziwne, żeby działało ,
  1. echo 'var tura1;
  2. tura1=tura0+"<font size=2>tekst '.$l_r.'<br>"; setTimeout("document.getElementById('log').innerHTML=tura1;",2000);';
  3. 1*
  4.  
  5. 1* nie możesz użyć apostrofu , jak coś to setTimeout("document.getElementById(\'log\')


Ten post edytował kamillo121 11.05.2010, 20:22:47
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: 22.08.2025 - 12:54