Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Dynamiczne zakładki - nie działają 2 panele na raz
Forum PHP.pl > Forum > PHP
Diego22
Witam buduję Stronę na php-fusion , chciałem dodać 2 panele po prawej z stronie z dynamicznymi zakładkami , jak jest tylko jeden panel włączony to wszystko jet ok , problem pojawia się gdy włącze 2 panel , to wtedy już nie działa. Jak klikam w zakładki w drugim panelu , to zawartość ich zmienia się w pierwszym , mimo że nie klikałem w nim. Jak to rowiązać ? Oto kod :
Kod
openside("Klasyfikacje"); ?>

    <script>
    //<![CDATA[
    function pokazdiv(el) {
    for(var i=1; i<=3; i++) {
    if(el == i) {
    document.getElementById(el).style.display = "block";
    }else{
    document.getElementById(i).style.display = "none";
    }
    }
    }
    //]]>
    </script>
    
    
    
    
    <a href="java script:void(0);" onclick="pokazdiv('1');">Galeria</a>
    <a href="java script:void(0);" onclick="pokazdiv('2');">Filmy</a>
    <a href="java script:void(0);" onclick="pokazdiv('3');">Ogolne</a>
    
    <div id="1">jeden</div>
    <div id="2" style="display:none">dwa</div>
    <div id="3" style="display:none">trzy</div>



<?php closeside();
morbic
ID każdego DIVa musi być unikatowe dla całego dokumentu HTML.

Najlepiej zrobić:

  1. //<![CDATA[
  2. function pokazdiv(el, panel) {
  3. for(var i=1; i<=3; i++) {
  4. if(el == i) {
  5. document.getElementById(panel+'_'+el).style.display = "block";
  6. }else{
  7. document.getElementById(panel+'_'+i).style.display = "none";
  8. }
  9. }
  10. return false;
  11. }
  12. //]]>
  13.  
  14. <a href="#" onclick="return pokazdiv('1', 'panel1');">Galeria</a>
  15. <a href="#" onclick="return pokazdiv('2', 'panel1');">Filmy</a>
  16. <a href="#" onclick="return pokazdiv('3', 'panel1');">Ogolne</a>
  17.  
  18. <div id="panel1_1">jeden</div>
  19. <div id="panel1_2" style="display:none">dwa</div>
  20. <div id="panel1_3" style="display:none">trzy</div>


Dla kolejnych paneli zmieniasz tylko drugi parametr funkcji pokazdiv() i pierwszy człon id wszystkich divów w panelu.
Diego22
hmm a w tym panelu jak będzie ?
zmieniłem id ale nie działały oba ;/
kod:
  1. openside("Klasyfikacje"); ?>
  2.  
  3. <script>
  4. //<![CDATA[
  5. function pokazdiv(el) {
  6. for(var i=1; i<=3; i++) {
  7. if(el == i) {
  8. document.getElementById(el).style.display = "block";
  9. }else{
  10. document.getElementById(i).style.display = "none";
  11. }
  12. }
  13. }
  14. //]]>
  15. </script>
  16.  
  17. <center>
  18. <b>
  19. <a href="java script:void(0);" onclick="pokazdiv('1');">Kierowców</a> |
  20. <a href="java script:void(0);" onclick="pokazdiv('2');">Konstruktorów</a>
  21. </b>
  22. </center>
  23. <div id="1" style="display: block; ">
  24. <br><b><center>Klasyfikacja Kierowców</center></b><br>
  25. <center><table style=' text-align: left; width: 261px; height: 119px;'
  26. background='http://rfleague.xaa.pl/themes/Liga2011/images/Strona2/tlokla.png'
  27. border='0' cellpadding='0' cellspacing='0'>
  28. <tbody>
  29. <tr>
  30. <td style='vertical-align: top; font-weight: bold;
  31. text-align: center; width: 60px; color: rgb(255, 255,
  32. 255);'>1.<br>
  33. </td>
  34. <td style='vertical-align: top; width: 150px; height:
  35. 25px; color: rgb(255, 255, 255); font-weight: bold;
  36. text-align: center;'>&nbsp;&nbsp; nick &nbsp;&nbsp; <br>
  37. </td>
  38. <td style='vertical-align: top; font-weight: bold;
  39. text-align: left; color: rgb(255, 255, 255);'>0<br>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td style='vertical-align: top; font-weight: bold;
  44. text-align: center; color: rgb(255, 255, 255);'>2.<br>
  45. </td>
  46. <td style=' vertical-align: top; color: rgb(255, 255,
  47. 255); font-weight: bold; text-align: center; width:
  48. 150px;'>nick<br>
  49. </td>
  50. <td style='vertical-align: top; height: 23px; font-weight:
  51. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  52. </td>
  53. </tr>
  54. <tr>
  55. <td style='vertical-align: top; font-weight: bold;
  56. text-align: center; color: rgb(255, 255, 255);'>3.<br>
  57. </td>
  58. <td style='vertical-align: top; color: rgb(255, 255, 255);
  59. font-weight: bold; text-align: center;'>nick<br>
  60. </td>
  61. <td style='vertical-align: top; height: 23px; font-weight:
  62. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  63. </td>
  64. </tr>
  65. <tr>
  66. <td style='vertical-align: top; font-weight: bold;
  67. text-align: center; color: rgb(255, 255, 255);'>4.<br>
  68. </td>
  69. <td style='vertical-align: top; color: rgb(255, 255, 255);
  70. font-weight: bold; text-align: center;'>nick<br>
  71. </td>
  72. <td style='vertical-align: top; height: 23px; font-weight:
  73. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td style=' vertical-align: top; font-weight: bold;
  78. text-align: center; color: rgb(255, 255, 255);'>5.<br>
  79. </td>
  80. <td style='vertical-align: top; color: rgb(255, 255, 255);
  81. font-weight: bold; text-align: center;'>nick<br>
  82. </td>
  83. <td style='vertical-align: top; height: 23px; font-weight:
  84. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  85. </td>
  86. </tr>
  87. </tbody>
  88. </table></center>
  89. <b><center><a href='http://rfleague.xaa.pl/viewpage.php?page_id=1' >pełna</a></center></b>
  90. </div>
  91.  
  92.  
  93. <div id="2" style="display: none; ">
  94. <br><b><center>Klasyfikacja Konstruktorów</center></b><br>
  95. <center><table style=' text-align: left; width: 261px; height: 119px;'
  96. background='http://rfleague.xaa.pl/themes/Liga2011/images/Strona2/tlokla.png'
  97. border='0' cellpadding='0' cellspacing='0'>
  98. <tbody>
  99. <tr>
  100. <td style='vertical-align: top; font-weight: bold;
  101. text-align: center; width: 60px; color: rgb(255, 255,
  102. 255);'>1.<br>
  103. </td>
  104. <td style='vertical-align: top; width: 150px; height:
  105. 25px; color: rgb(255, 255, 255); font-weight: bold;
  106. text-align: center;'>&nbsp;&nbsp; RedBull &nbsp;&nbsp; <br>
  107. </td>
  108. <td style='vertical-align: top; font-weight: bold;
  109. text-align: left; color: rgb(255, 255, 255);'>0<br>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td style='vertical-align: top; font-weight: bold;
  114. text-align: center; color: rgb(255, 255, 255);'>2.<br>
  115. </td>
  116. <td style=' vertical-align: top; color: rgb(255, 255,
  117. 255); font-weight: bold; text-align: center; width:
  118. 150px;'>McLaren<br>
  119. </td>
  120. <td style='vertical-align: top; height: 23px; font-weight:
  121. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  122. </td>
  123. </tr>
  124. <tr>
  125. <td style='vertical-align: top; font-weight: bold;
  126. text-align: center; color: rgb(255, 255, 255);'>3.<br>
  127. </td>
  128. <td style='vertical-align: top; color: rgb(255, 255, 255);
  129. font-weight: bold; text-align: center;'>Mercedes<br>
  130. </td>
  131. <td style='vertical-align: top; height: 23px; font-weight:
  132. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td style='vertical-align: top; font-weight: bold;
  137. text-align: center; color: rgb(255, 255, 255);'>4.<br>
  138. </td>
  139. <td style='vertical-align: top; color: rgb(255, 255, 255);
  140. font-weight: bold; text-align: center;'>Ferrari<br>
  141. </td>
  142. <td style='vertical-align: top; height: 23px; font-weight:
  143. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td style=' vertical-align: top; font-weight: bold;
  148. text-align: center; color: rgb(255, 255, 255);'>5.<br>
  149. </td>
  150. <td style='vertical-align: top; color: rgb(255, 255, 255);
  151. font-weight: bold; text-align: center;'>Sahara<br>
  152. </td>
  153. <td style='vertical-align: top; height: 23px; font-weight:
  154. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  155. </td>
  156. </tr>
  157. </tbody>
  158. </table></center>
  159. <b><center><a href='http://rfleague.xaa.pl/viewpage.php?page_id=7' >pełna</a></center></b>
  160.  
  161.  
  162.  
  163. </div>
  164.  
  165. <?php closeside();
morbic
Przeczytaj jeszcze raz kod, który napisałem i porównaj go ze swoim. W kodzie, który wkleiłeś przed chwilą nic nie jest zmienione.
Diego22
To jak w pierwszym panelu mam kod taki jak wyżej post co dodałem a w , drugim dodam taki :
Kod
openside("Klasyfikacje"); ?>

   <script>
    //<![CDATA[
    function pokazdiv(el, panel) {
    for(var i=1; i<=3; i++) {
    if(el == i) {
    document.getElementById(panel+'_'+el).style.display = "block";
    }else{
    document.getElementById(panel+'_'+i).style.display = "none";
    }
    }
    return false;
    }
    //]]>
    </script>
    
    <a href="#" onclick="return pokazdiv('1', 'panel1');">Galeria</a>
    <a href="#" onclick="return pokazdiv('2', 'panel1');">Filmy</a>
    
    
<div id="panel1_1" style="display: block; ">
<br><b><center>Klasyfikacja Kierowców</center></b><br>
<center><table style=' text-align: left; width: 261px; height: 119px;'
background='http://rfleague.xaa.pl/themes/Liga2011/images/Strona2/tlokla.png'
border='0' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; width: 60px; color: rgb(255, 255,
255);'>1.<br>
</td>
<td style='vertical-align: top; width: 150px; height:
25px; color: rgb(255, 255, 255); font-weight: bold;
text-align: center;'>   nick    <br>
</td>
<td style='vertical-align: top; font-weight: bold;
text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>2.<br>
</td>
<td style=' vertical-align: top; color: rgb(255, 255,
255); font-weight: bold; text-align: center; width:
150px;'>nick<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>3.<br>
</td>
<td style='vertical-align: top; color: rgb(255, 255, 255);
font-weight: bold; text-align: center;'>nick<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>4.<br>
</td>
<td style='vertical-align: top; color: rgb(255, 255, 255);
font-weight: bold; text-align: center;'>nick<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style=' vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>5.<br>
</td>
<td style='vertical-align: top; color: rgb(255, 255, 255);
font-weight: bold; text-align: center;'>nick<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
</tbody>
</table></center>
<b><center><a href='http://rfleague.xaa.pl/viewpage.php?page_id=1' >pełna</a></center></b>
</div>


<div id="panel1_2" style="display: none; ">
<br><b><center>Klasyfikacja Konstruktorów</center></b><br>
<center><table style=' text-align: left; width: 261px; height: 119px;'
background='http://rfleague.xaa.pl/themes/Liga2011/images/Strona2/tlokla.png'
border='0' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; width: 60px; color: rgb(255, 255,
255);'>1.<br>
</td>
<td style='vertical-align: top; width: 150px; height:
25px; color: rgb(255, 255, 255); font-weight: bold;
text-align: center;'>   RedBull    <br>
</td>
<td style='vertical-align: top; font-weight: bold;
text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>2.<br>
</td>
<td style=' vertical-align: top; color: rgb(255, 255,
255); font-weight: bold; text-align: center; width:
150px;'>McLaren<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>3.<br>
</td>
<td style='vertical-align: top; color: rgb(255, 255, 255);
font-weight: bold; text-align: center;'>Mercedes<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style='vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>4.<br>
</td>
<td style='vertical-align: top; color: rgb(255, 255, 255);
font-weight: bold; text-align: center;'>Ferrari<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
<tr>
<td style=' vertical-align: top; font-weight: bold;
text-align: center; color: rgb(255, 255, 255);'>5.<br>
</td>
<td style='vertical-align: top; color: rgb(255, 255, 255);
font-weight: bold; text-align: center;'>Sahara<br>
</td>
<td style='vertical-align: top; height: 23px; font-weight:
bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
</td>
</tr>
</tbody>
</table></center>
<b><center><a href='http://rfleague.xaa.pl/viewpage.php?page_id=7' >pełna</a></center></b>
    


    </div>

<?php closeside();


To mi wogule nie działa wtedy pierwszy panel
morbic
Bo funkcja pokazdiv() nie może być zdefiniowana dwa razy.
Diego22
to teraz co mam z tym zrobić ?

pomoże ktoś ?
Lwik
Hmm, tylko, że błędu nie masz w tym kodzie. Wrzuć sobie go jako czystą stronę.

  1. //<![CDATA[
  2. function pokazdiv(el, panel) {
  3. for(var i=1; i<=3; i++) {
  4. if(el == i) {
  5. document.getElementById(panel+'_'+el).style.display = "block";
  6. }else{
  7. document.getElementById(panel+'_'+i).style.display = "none";
  8. }
  9. }
  10. return false;
  11. }
  12. //]]>
  13. </script>
  14.  
  15. <a href="#" onclick="return pokazdiv('1', 'panel1');">Galeria</a>
  16. <a href="#" onclick="return pokazdiv('2', 'panel1');">Filmy</a>
  17.  
  18.  
  19. <div id="panel1_1" style="display: block; ">
  20. <br><b><center>Klasyfikacja Kierowców</center></b><br>
  21. <center><table style=' text-align: left; width: 261px; height: 119px;'
  22. background='http://rfleague.xaa.pl/themes/Liga2011/images/Strona2/tlokla.png'
  23. border='0' cellpadding='0' cellspacing='0'>
  24. <tr>
  25. <td style='vertical-align: top; font-weight: bold;
  26. text-align: center; width: 60px; color: rgb(255, 255,
  27. 255);'>1.<br>
  28. </td>
  29. <td style='vertical-align: top; width: 150px; height:
  30. 25px; color: rgb(255, 255, 255); font-weight: bold;
  31. text-align: center;'> nick <br>
  32. </td>
  33. <td style='vertical-align: top; font-weight: bold;
  34. text-align: left; color: rgb(255, 255, 255);'>0<br>
  35. </td>
  36. </tr>
  37. <tr>
  38. <td style='vertical-align: top; font-weight: bold;
  39. text-align: center; color: rgb(255, 255, 255);'>2.<br>
  40. </td>
  41. <td style=' vertical-align: top; color: rgb(255, 255,
  42. 255); font-weight: bold; text-align: center; width:
  43. 150px;'>nick<br>
  44. </td>
  45. <td style='vertical-align: top; height: 23px; font-weight:
  46. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td style='vertical-align: top; font-weight: bold;
  51. text-align: center; color: rgb(255, 255, 255);'>3.<br>
  52. </td>
  53. <td style='vertical-align: top; color: rgb(255, 255, 255);
  54. font-weight: bold; text-align: center;'>nick<br>
  55. </td>
  56. <td style='vertical-align: top; height: 23px; font-weight:
  57. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td style='vertical-align: top; font-weight: bold;
  62. text-align: center; color: rgb(255, 255, 255);'>4.<br>
  63. </td>
  64. <td style='vertical-align: top; color: rgb(255, 255, 255);
  65. font-weight: bold; text-align: center;'>nick<br>
  66. </td>
  67. <td style='vertical-align: top; height: 23px; font-weight:
  68. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  69. </td>
  70. </tr>
  71. <tr>
  72. <td style=' vertical-align: top; font-weight: bold;
  73. text-align: center; color: rgb(255, 255, 255);'>5.<br>
  74. </td>
  75. <td style='vertical-align: top; color: rgb(255, 255, 255);
  76. font-weight: bold; text-align: center;'>nick<br>
  77. </td>
  78. <td style='vertical-align: top; height: 23px; font-weight:
  79. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  80. </td>
  81. </tr>
  82. <b><center><a href='http://rfleague.xaa.pl/viewpage.php?page_id=1' >pełna</a></center></b>
  83. </div>
  84.  
  85.  
  86. <div id="panel1_2" style="display: none; ">
  87. <br><b><center>Klasyfikacja Konstruktorów</center></b><br>
  88. <center><table style=' text-align: left; width: 261px; height: 119px;'
  89. background='http://rfleague.xaa.pl/themes/Liga2011/images/Strona2/tlokla.png'
  90. border='0' cellpadding='0' cellspacing='0'>
  91. <tr>
  92. <td style='vertical-align: top; font-weight: bold;
  93. text-align: center; width: 60px; color: rgb(255, 255,
  94. 255);'>1.<br>
  95. </td>
  96. <td style='vertical-align: top; width: 150px; height:
  97. 25px; color: rgb(255, 255, 255); font-weight: bold;
  98. text-align: center;'> RedBull <br>
  99. </td>
  100. <td style='vertical-align: top; font-weight: bold;
  101. text-align: left; color: rgb(255, 255, 255);'>0<br>
  102. </td>
  103. </tr>
  104. <tr>
  105. <td style='vertical-align: top; font-weight: bold;
  106. text-align: center; color: rgb(255, 255, 255);'>2.<br>
  107. </td>
  108. <td style=' vertical-align: top; color: rgb(255, 255,
  109. 255); font-weight: bold; text-align: center; width:
  110. 150px;'>McLaren<br>
  111. </td>
  112. <td style='vertical-align: top; height: 23px; font-weight:
  113. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  114. </td>
  115. </tr>
  116. <tr>
  117. <td style='vertical-align: top; font-weight: bold;
  118. text-align: center; color: rgb(255, 255, 255);'>3.<br>
  119. </td>
  120. <td style='vertical-align: top; color: rgb(255, 255, 255);
  121. font-weight: bold; text-align: center;'>Mercedes<br>
  122. </td>
  123. <td style='vertical-align: top; height: 23px; font-weight:
  124. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td style='vertical-align: top; font-weight: bold;
  129. text-align: center; color: rgb(255, 255, 255);'>4.<br>
  130. </td>
  131. <td style='vertical-align: top; color: rgb(255, 255, 255);
  132. font-weight: bold; text-align: center;'>Ferrari<br>
  133. </td>
  134. <td style='vertical-align: top; height: 23px; font-weight:
  135. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  136. </td>
  137. </tr>
  138. <tr>
  139. <td style=' vertical-align: top; font-weight: bold;
  140. text-align: center; color: rgb(255, 255, 255);'>5.<br>
  141. </td>
  142. <td style='vertical-align: top; color: rgb(255, 255, 255);
  143. font-weight: bold; text-align: center;'>Sahara<br>
  144. </td>
  145. <td style='vertical-align: top; height: 23px; font-weight:
  146. bold; text-align: left; color: rgb(255, 255, 255);'>0<br>
  147. </td>
  148. </tr>
  149. <b><center><a href='http://rfleague.xaa.pl/viewpage.php?page_id=7' >pełna</a></center></b>
  150.  
  151.  
  152.  
  153. </div>

Obstawiam, że Firebug nie zwróci nic niepożądanego.
Co do elementu z którym się gryzie - zgubiłem szklaną kulę, bez wpisu z firebuga / linku do strony nie jestem w stanie nic zlokalizować.
Diego22
1 panel działa jak dam 2 to już nic ;/

mam podać link do www?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.