Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] zmiana diva
escobar1983
post
Post #1





Grupa: Zarejestrowani
Postów: 198
Pomógł: 0
Dołączył: 31.01.2008

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


Witam , problem polega na tym ze chcialbym zrobic sobie liste np.
  1. <?php
  2. <ul >
  3. <li><a name="a">1</a></li>
  4. <li><a name="a">2</a></li>
  5.  
  6. </ul>
  7. ?>
I teraz po nacisnieciu ktoregos z linkow pokazaly mi sie info na temat tego linku pod ta lista.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 9)
Cezar708
post
Post #2





Grupa: Zarejestrowani
Postów: 1 116
Pomógł: 119
Dołączył: 10.05.2005
Skąd: Poznań

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


na przykład:

  1. function showInfo(id){
  2. document.getElementById(id).style.display = 'block';
  3. }
  4. <ul >
  5. <li><a name="a" onclick="showInfo('l1')">1</a>
  6. <div id="l1" style="display: none;">
  7. info o linku 1
  8. </div>
  9. </li>
  10. <li><a name="a" onclick="showInfo('l2')" style="display: none;">2</a>
  11. <div id="l2">
  12. info o linku 2
  13. </div>
  14. </li>
  15.  
  16. </ul>


~EDIT
zapomniałe o style="display: none;" pozdrawiam smile.gif

Ten post edytował Cezar708 18.03.2008, 16:22:59
Go to the top of the page
+Quote Post
escobar1983
post
Post #3





Grupa: Zarejestrowani
Postów: 198
Pomógł: 0
Dołączył: 31.01.2008

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


  1. <?php
  2. <li><a name="a" onclick="showInfo('l2')" style="display: none;">2.....</a></li>
  3. ?>

wogole go nie widac:/

Dzieki za pomoc exclamation.gif

Jak zrobic zeby po nacisnieciu drugi raz na link z listy badz nacisniecie innego linku z listy poprzedni byl display:none questionmark.gif

Ten post edytował escobar1983 18.03.2008, 16:32:19
Go to the top of the page
+Quote Post
Cezar708
post
Post #4





Grupa: Zarejestrowani
Postów: 1 116
Pomógł: 119
Dołączył: 10.05.2005
Skąd: Poznań

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


szybko pisałem i mały błąd się wdarł,

poprawna wersja:

  1. function showInfo(id){
  2. document.getElementById(id).style.display = 'block';
  3. }
  4. <ul >
  5. <li><a name="a" onclick="showInfo('l1')">1</a>
  6. <div id="l1" style="display: none;">
  7. info o linku 1
  8. </div>
  9. </li>
  10. <li><a name="a" onclick="showInfo('l2')">2</a>
  11. <div id="l2" style="display: none;">
  12. info o linku 2
  13. </div>
  14. </li>
  15.  
  16. </ul>


~EDIT:
mała przeróbka (po Twoim edytowaniu smile.gif )
  1. function showInfo(id){
  2. if ( document.getElementById(id).style.display == 'block' ){
  3. document.getElementById(id).style.display = 'none';
  4. } else {
  5. document.getElementById(id).style.display = 'block';
  6. }
  7. }
  8. <ul >
  9. <li><a name="a" onclick="showInfo('l1')">1</a>
  10. <div id="l1" style="display: none;">
  11. info o linku 1
  12. </div>
  13. </li>
  14. <li><a name="a" onclick="showInfo('l2')">2</a>
  15. <div id="l2" style="display: none;">
  16. info o linku 2
  17. </div>
  18. </li>
  19. </ul>


Ten post edytował Cezar708 18.03.2008, 16:35:01
Go to the top of the page
+Quote Post
escobar1983
post
Post #5





Grupa: Zarejestrowani
Postów: 198
Pomógł: 0
Dołączył: 31.01.2008

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


Ok a co z ukrywaniem??
Go to the top of the page
+Quote Post
logas
post
Post #6





Grupa: Zarejestrowani
Postów: 17
Pomógł: 1
Dołączył: 15.03.2008

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


  1. <?php
  2. ...
  3. ?>
  4. <ul ="\"\"\"\"">
  5. <a  name="\"\"\"a\"\"\"">1
  6. <LI><a  name="\"\"\"a\"\"\"">2
  7.  
  8.  
  9. ...
  10. ?>
Sorka nie doczytałem do końca myslałem ze wyrzuca ci błąd

Ten post edytował logas 18.03.2008, 16:40:41
Go to the top of the page
+Quote Post
Cezar708
post
Post #7





Grupa: Zarejestrowani
Postów: 1 116
Pomógł: 119
Dołączył: 10.05.2005
Skąd: Poznań

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


Cytat
Ok a co z ukrywaniem??


w poprzednim poście edytowałem go... ech się wymijamy w postowaniu smile.gif smile.gif

Ten post edytował Cezar708 18.03.2008, 16:36:08
Go to the top of the page
+Quote Post
escobar1983
post
Post #8





Grupa: Zarejestrowani
Postów: 198
Pomógł: 0
Dołączył: 31.01.2008

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


Sorry ze tak zawracam gittarre ale jak zrobic ze jak mam wyswietlony pierwszy i nacisne drugi to ten pierwszy zniknie a nie naloza sie na siebie??
Go to the top of the page
+Quote Post
Cezar708
post
Post #9





Grupa: Zarejestrowani
Postów: 1 116
Pomógł: 119
Dołączył: 10.05.2005
Skąd: Poznań

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


ależ proszę bardzo:
  1. function showInfo(id){
  2. var divy = document.getElementsByTagName('div');
  3. for ( var i=0; i<divy.length; i++ ){
  4. if ( divy[i].id.substring(0,4) == 'info' ){
  5. if ( divy[i].id == id ){
  6. if ( divy[i].style.display == 'block' ){
  7. divy[i].style.display = 'none';
  8. } else {
  9. divy[i].style.display = 'block';
  10. }
  11. } else {
  12. divy[i].style.display = 'none';
  13. }
  14. }
  15. }
  16. }
  17. <ul >
  18. <li><a name="a" onclick="showInfo('info1')">1</a>
  19. <div id="info1" style="display: none;">
  20. info o linku 1
  21. </div>
  22. </li>
  23. <li><a name="a" onclick="showInfo('info2')">2</a>
  24. <div id="info2" style="display: none;">
  25. info o linku 2
  26. </div>
  27. </li>
  28. </ul>


pozdrawiam
Go to the top of the page
+Quote Post
escobar1983
post
Post #10





Grupa: Zarejestrowani
Postów: 198
Pomógł: 0
Dołączył: 31.01.2008

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


Cezar708 Dzieki wielkie!! smile.gif
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 09:34