Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js] automatyczna zamiana linku
!*!
post
Post #1





Grupa: Zarejestrowani
Postów: 4 298
Pomógł: 447
Dołączył: 16.11.2006

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


hmm nie mogę chyba wczytać tego z funkcji odczytywanej przez osobny plik js, a to dlatego że php musi odczytywać ciągle nowe zmienne. Zrobiłem coś takiego:

  1. <?php
  2. echo '<div style="cursor:pointer;" name="'.$f.'" onClick="document.getElementById(''.$wiersz['login'].'').style.display='block';">rozwiń</div>';
  3. echo '<div style="display: none" id="'.$wiersz['login'].'"><br /><a href="gg:'.$wiersz[dom].'"></a>
  4. <div style="cursor:pointer;" name="'.$f.'" onClick="document.getElementById(''.$wiersz['login'].'').style.display='none';">zwiń</div>
  5. </div>';
  6. ?>


wszystko wczytywane jest przez while i dodawane do każdego wyniku z osobna... ale czy jest możliwość w tym JS utworzenia jednego diva który będzie na poczatku wyświetlał "rozwiń" a po kliknieciu w niego zamieni się automatycznie w "zwiń" ?

Ten post edytował !*! 29.03.2008, 11:11:13
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
arecki
post
Post #2





Grupa: Zarejestrowani
Postów: 222
Pomógł: 35
Dołączył: 6.02.2005

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


Spróbuj dostosować to do swoich potrzeb :

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Insert title here</title>
  6. <style type="text/css">
  7.  
  8. .divA {
  9. border: 1px solid #222;
  10. padding: 10px;
  11. width: 100px;
  12. }
  13.  
  14. <script type="text/javascript">
  15. //<![CDATA[
  16.  
  17. function showOrHideDivWithTextChange(divId, divWithText) {
  18. var div = document.getElementById(divId);
  19. if(div.style.display == 'block') {
  20. div.style.display = 'none';
  21. divWithText.innerHTML = 'rozwiń';
  22. } else {
  23. div.style.display = 'block';
  24. divWithText.innerHTML = 'zwiń';
  25. }
  26. }
  27.  
  28. //]]>
  29. </head>
  30.  
  31. <div style="cursor:pointer;" id="textToChange" onClick="javascript:showOrHideDivWithTextChange('login_name', this);">rozwiń</div>
  32. <div style="display: none" id="login_name" class="divA"><a href="gg:1234">numer gg</a></div>
  33.  
  34. </body>
  35. </html>
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: 11.10.2025 - 19:10