Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX JS] onLoad dla 3 div przy załadowaniu strony
HBK
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 3.08.2008

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


Mam 3 funkcje (robią to samo):

  1. function ustaw1(str)
  2. {
  3. if (str=="")
  4. {
  5. document.getElementById("ustaw1").innerHTML="";
  6. return;
  7. }
  8. if (window.XMLHttpRequest)
  9. {// code for IE7+, Firefox, Chrome, Opera, Safari
  10. xmlhttp=new XMLHttpRequest();
  11. }
  12. else
  13. {// code for IE6, IE5
  14. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  15. }
  16. xmlhttp.onreadystatechange=function()
  17. {
  18. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  19. {
  20. document.getElementById("ustaw1").innerHTML=xmlhttp.responseText;
  21. }
  22. }
  23. xmlhttp.open("GET","ccq.php?q="+str,true);
  24. xmlhttp.send();
  25. }
  26.  
  27.  
  28.  
  29. function ustaw2(str)
  30.  
  31. (...)
  32.  
  33.  
  34.  
  35. function ustaw3(str)
  36.  
  37. (...)
  38.  



Oraz 3 divy:

<div id="ustaw1"></div>
<div id="ustaw2"></div>
<div id="ustaw3"></div>


Usiłuję uzyskać taki efekt, że po wejściu na stronę wykonają się te 3 funkcje i wyświetlą się zawartości divów.


Wywołanie tego:

<script type="text/javascript">

ustaw1(<?php echo $salon_1; ?>);
ustaw2(<?php echo $salon_2; ?>);
ustaw3(<?php echo $salon_3; ?>);

</script>

Wyświetla się tylko ostatni div (<div id="ustaw3"></div>)


Jak zmusić żeby się te 3 funkcje wykonały na raz?


onLoad w body też ten sam efekt.

Ten post edytował HBK 11.10.2011, 17:27:27
Go to the top of the page
+Quote Post

Posty w temacie


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: 23.08.2025 - 12:54