Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] Problem ze skryptem do naprzemiennego kolorwania wierszy
martinstw
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 0
Dołączył: 1.11.2008

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


Witam!

Czy mógłby mi ktoś powiedzieć dlaczego tło wierszy nie jest pokolorowane naprzemiennie?

Kod skryptu jest następujący:

Kod
<style type="text/css">
        
        #tabela1 {border: 1px solid black;}
            .th1 {border: 1px solid black; color: red; background-color: aqua;}
            .th2 {border: 1px solid black; background-color: yellow;}
            .th3 {border: 1px solid black; background-color: yellow;}
            .th4 {border: 1px solid black; background-color: yellow;}
            .th5 {border: 1px solid black; background-color: yellow;}
            .th6 {border: 1px solid black; background-color: yellow;}
            .th7 {border: 1px solid black; background-color: yellow;}
            .th8 {border: 1px solid black; background-color: yellow;}
            .th9 {border: 1px solid black; background-color: yellow;}
            .th10 {border: 1px solid black; background-color: yellow;}
            .th11 {border: 1px solid black; background-color: yellow;}
            .th12 {border: 1px solid black; background-color: yellow;}
        
            .th {width: 5px;}
            .status {width: 50px;}
            .nazwa {width: 120px;;}
            .haslo {width: 130px;}
            .przypomnienie {width: 87px;}
            .rejestracja {width: 100px;}
            .imie {width: 110px;}
            .nazwisko {width: 160px;}
            .nr_kont {width: 90px;}
            .wydzial {width: 150px;}
            .funkcja {width: 100px;}
            
            #tabela1 {background-color: #F9F9F9;}
            #tabela1 tr.even {background-color: #EAF1FD}
        
        
        #tabela2 {width: 100%;}
            .print {width:40px; height:40px; text-align: center; border: 1px solid black;}
            .podpis {height:40px; width: 230px; background-color: silver;  color: blue; text-align: center; border: 1px solid black; font-weight:  bold; font-style: italic;}
            .refresh {width:40px; height:40px; border: 1px solid black;}
            .date_hour {width: 160px; height: 0px; text-align: center; border: 1px solid black;}
            .actualizacja {height:20px; text-align: center; border: 1px solid black;}
            .znajdz {width:200px;  height: 40px; border: 1px solid black;}
            .znajdz1 {width:40px;  height: 40px; border: 1px solid black;}
            .wstaw_wiersz {width:40px;  height: 40px; border: 1px solid black;}
            .usun_wiersz {width:40px;  height: 40px; border: 1px solid black;}
            .zapisz {width:40px;  height: 40px; border: 1px solid black;}
            .wyloguj {width:40px;  height: 40px; border: 1px solid black;}
            .btn_search, btn_insert_row, btn_delete_row, btn_save, btn_refresh,  btn_logout {height: 40px; width: 40px; background: snow;}
            
        </style>
        
        
        
        <!--Naprzemienne tło w wierszach-->
        
         <script type="text/javascript">
             function stripe()
        {
            var tab = document.getElementById('tabela1');
            var rows = tab.getElementsByTagName('tr');
            var even = false;
        
            for (var i=0; i<rows.length; i++)
            {
                if (even)
                    rows[i].className += " even";
        
                even = !even;
            }
        }
            </script></code>[code]<BODY onload="initSort()">
  
   <BODY  onload="datetime()">
  
   <body onload="stripe()">
  
   <table id="tabela1">
   <tr>
       <th class="th1" colspan=13>Wykaz</th>
   </tr>
   <tr>
       <td class="th2">&nbsp</td>
       <td class="th3"><a href="javascript: var y; Sortuj(1);">Status</a></td>
       <td class="th4"><a href="javascript: var y; Sortuj(2);">Nazwa</a></td>
       <td class="th5">Hasło</td>
       <td class="th6">Przypomnienie</td>
       <td class="th7"><a href="javascript: var y; Sortuj(5);">Data reje.</a></td>
       <td class="th8">Imię</td>
       <td class="th9"><a href="javascript: var y; Sortuj(7);">Nazwisko</a></td>
       <td class="th10"><a href="javascript: var y; Sortuj(8);">Nr kont.</a></td>
       <td class="th11"><a href="javascript: var y; Sortuj(9);">Wydz.</a></td>
       <td class="th12"><a href="javascript: var y; Sortuj(10);">Fun.</a></td></tr>
      
   <tbody id="Sort_id">
   <tr><td class="th"><input type="checkbox" name="wybor"  value="1"></td><td  class="status">printer</td><td  class="nazwa">martinstw</td><td  class="haslo">martinstw78</td><td  class="przypomnienie">15.12.1987</td><td  class="rejestracja">19.02.1989</td><td  class="imie">Marcin</td><td  class="nazwisko">PPP</td><td  class="nr_kont">12345</td><td class="wydzial">WMWG-  SG</td><td class="funkcja">Użytkownik2</td></tr>
   <tr><td class="th"><input type="checkbox" name="wybor"  value="1"></td><td class="status">see</td><td  class="nazwa">danek</td><td  class="haslo">danek12</td><td  class="przypomnienie">13.12.1987</td><td  class="rejestracja">16.02.1989</td><td  class="imie">Daniel</td><td  class="nazwisko">MMMM</td><td  class="nr_kont">52341</td><td class="wydzial">WMWG-  aa</td><td class="funkcja">Użytkownik1</td></tr>
   </tbody>
   </table>


Dodatkowo nie wiem jak umieścić w jednym body:

Kod
<BODY onload="initSort()">  
          
        <BODY  onload="datetime()">  
          
        <body onload="stripe()">


Taka wersja też nie działa:

Kod
<script type="text/javascript">  
             document.onload = function()  
        {  
          initSort();  
          datetime();  
          stripe();  
        }  
        </script>


Ten post edytował martinstw 31.12.2008, 11:14:56
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: 22.08.2025 - 20:34