Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> ukrywanie wielu td
Dex1987
post 10.04.2006, 13:27:04
Post #1





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

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


Witam,

mam taki kodzik

  1.  
  2. function ShowHide (open, close) {
  3.  
  4.                   if (open != '') {
  5.  
  6.                       expMenu (open);
  7.                   }
  8.  
  9.                   if (close != '') {
  10.  
  11.                       expMenu (close);
  12.                   }
  13. }
  14.  
  15. function expMenu (id) {
  16.  
  17.                  var item = null;
  18.  
  19.                  if (document.getElementById) {
  20.  
  21.                      item = document.getElementById(id);
  22.  
  23.                  } else if (document.all) {
  24.  
  25.                             item = document.all[id];
  26.  
  27.                  } else if (document.layers){
  28.  
  29.                             item = document.layers[id];
  30.                  }
  31.  
  32.                  if (!item) {
  33.  
  34.                      // do nothing
  35.  
  36.                  } else if (item.style) {
  37.  
  38.                             if (item.style.display == "none") {
  39.  
  40.                                 item.style.display = "";
  41.  
  42.                             } else {
  43.  
  44.                                 item.style.display = "none";
  45.                             }
  46.  
  47.                  } else {
  48.  
  49.                             item.visibility = "show";
  50.                  }
  51. }
  52.  
  53.  
  54.      <table border="0" align="center" cellpadding="0" cellspacing="0" width="90%" height="1">
  55.        <tr>
  56.          <td height="25" width="249" valign="top">
  57.            <font face="Verdana" size="2" color="#094AAC">
  58.              <a href="javascript:ShowHide('qr_opena1175','qr_closeda1175');">+ Menu główne</a>
  59.            </font>
  60.          </td>
  61.        </tr>
  62.        <tr id="qr_opena1175" style="display:none;position:relative;">
  63.              <td height="25" style="border-bottom: 1px solid #E8E8E8;" onmouseover="style.backgroundColor='#F9F9F9';" onmouseout="style.backgroundColor='#FFFFFF';" width="249">
  64.                <font color="#4A4A4A" face="Verdana" size="2">
  65.                  <a href="home.html">&nbsp;&nbsp;&nbsp;Strona główna</a>
  66.                </font>
  67.              </td>
  68.            </tr>      
  69.        <tr id="qr_opena1175" style="display:none;position:relative;">
  70.              <td height="25" style="border-bottom: 1px solid #E8E8E8;" onmouseover="style.backgroundColor='#F9F9F9';" onmouseout="style.backgroundColor='#FFFFFF';" width="249">
  71.                <font color="#4A4A4A" face="Verdana" size="2">
  72.                  <a href="home.html">&nbsp;&nbsp;&nbsp;Strona główna</a>
  73.                </font>
  74.              </td>
  75.            </tr>
  76.        </table>


i teraz chce zrobic tak zeby po kliknieciu na "menu glowne" pokazywaly sie wszystkie komorki a nie tylko pierwsza. Zastanawiam sie jeszcze czy nie mozna tego kodu uproscic?

Z gory dzieki za odpowiedz, pozdrawiam dex.
Go to the top of the page
+Quote Post
Zajec
post 10.04.2006, 17:02:45
Post #2





Grupa: Zarejestrowani
Postów: 1 086
Pomógł: 8
Dołączył: 10.12.2003

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


Cytat(Dex1987 @ 2006-04-10 13:27:04)
Zastanawiam sie jeszcze czy nie mozna tego kodu uproscic?.

  1. <script type="text/javascript">
  2.  
  3. function ShowHide (open, close) {
  4.      if (open != '')
  5.      expMenu(open);
  6.      if (close != '')
  7.      expMenu(close);
  8. }
  9.  
  10. function expMenu(id) {
  11.      var item = document.getElementById(id);
  12.  
  13.      if (item.style)
  14.      {
  15.            if (item.style.display == "none")
  16.            item.style.display = "";
  17.            else
  18.            item.style.display = "none";
  19.      }
  20. }
  21.  
  22. </script>


Ten post edytował Zajec 10.04.2006, 21:31:48
Go to the top of the page
+Quote Post
Dex1987
post 10.04.2006, 17:08:59
Post #3





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

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


niestety dziala tak jak dzialalo tyle ze po 2 kliknieciu sie juz nie chowa winksmiley.jpg
Go to the top of the page
+Quote Post
Zajec
post 10.04.2006, 21:30:52
Post #4





Grupa: Zarejestrowani
Postów: 1 086
Pomógł: 8
Dołączył: 10.12.2003

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


W moim poprzednim kodzie była linijka
Kod
tem.style.display = "none";
zamiast
Kod
item.style.display = "none";
. Poprawiłem.
Go to the top of the page
+Quote Post
Dex1987
post 11.04.2006, 10:48:57
Post #5





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

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


ok dziala tak jak dzialalo, pokazuje sie (chowa sie) tylko pierwszt td/tr.

Pozdrawiam dex.
Go to the top of the page
+Quote Post
revyag
post 11.04.2006, 12:16:34
Post #6





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

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


Nie możesz nadawać wierszom tego samego id. Jeśli już chcesz z tego korzystać to dla każdego zrób unikalne.
Poza tym da się to prościej zrobić smile.gif
Kod
<style type="text/css">
table tr.none {
    display:none;
}
table tr.visible {
    display:table-row;
}
</style>

Kod
<script type="text/javascript">
function ShowHide() {
    var trs = document.getElementsByTagName("tr");

    for (i in trs) {
        if(trs[i].className == 'none') {
            trs[i].className = 'visible'
        } else {
            if(trs[i].className == 'visible') {
                trs[i].className = 'none'
            }
        }
    }
}
</script>


  1. <table border="0" align="center" cellpadding="0" cellspacing="0" width="90%" height="1">
  2.       <tr>
  3.         <td height="25" width="249" valign="top">
  4.           <font face="Verdana" size="2" color="#094AAC">
  5.             <a href="javascript:ShowHide();">+ Menu główne</a>
  6.           </font>
  7.         </td>
  8.       </tr>
  9.       <tr class="none">
  10.             <td height="25" style="border-bottom: 1px solid #E8E8E8;" onmouseover="style.backgroundColor='#F9F9F9';" onmouseout="style.backgroundColor='#FFFFFF';" width="249">
  11.               <font color="#4A4A4A" face="Verdana" size="2">
  12.                 <a href="home.html">&nbsp;&nbsp;&nbsp;Strona główna</a>
  13.               </font>
  14.             </td>
  15.           </tr>      
  16.       <tr class="none" >
  17.             <td height="25" style="border-bottom: 1px solid #E8E8E8;" onmouseover="style.backgroundColor='#F9F9F9';" onmouseout="style.backgroundColor='#FFFFFF';" width="249">
  18.               <font color="#4A4A4A" face="Verdana" size="2">
  19.                 <a href="home.html">&nbsp;&nbsp;&nbsp;Strona główna</a>
  20.               </font>
  21.             </td>
  22.           </tr>
  23.       </table>


--------------------
-------------

------
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 Wersja Lo-Fi Aktualny czas: 27.06.2025 - 13:30