Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jquery]Kolorowanie wierszy w tabeli
marcwars
post
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 14.02.2011
Skąd: Wawa

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


Nie działa mi kolorowanie wierszy, próbowałem już różnych sposobów z jquery, ale lipa.
kod strony:
  1. <!DOCTYPE html>
  2. <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
  3. <script type='text/javascript' src='javascript.js'></script>
  4. <script type="text/javascript" src="jquery-1.7.1.js"></script>
  5.  
  6. <script type="text/javascript">
  7. $(function() {
  8. $("tr:even").addClass("striped");
  9. //$("table tr:nth-child(even)").addClass("striped");
  10. });
  11. </script>
  12. <link rel="stylesheet" type="text/css" href="style.css" />
  13. </head>
  14.  
  15. <form name='myForm'>
  16. Nazwa produktu: <input type='text' id='nazwa' /> <br />
  17. Cena produktu: <input type='text' id='cena' /><br />
  18. <input type='button' onclick='ajaxFunction()' value='Dodaj' />
  19. </form>
  20. <div id='ajaxDiv'>Your result will display here</div>
  21.  
  22. </body>
  23. </html>


W divie o id='ajaxDiv' wchodzi ajaksowany plik php- tutaj fragment od wstawiania tabeli:
  1. .....
  2. $display_string = '<table>';
  3. $display_string .= '<tr>';
  4. $display_string .= '<th>Produkt</th>';
  5. $display_string .= '<th>Cena</th>';
  6. $display_string .= '</tr>';
  7.  
  8. // Insert a new row in the table for each person returned
  9. while($row = mysql_fetch_array($result)){
  10. $display_string .= '<tr>';
  11. $display_string .= '<td>'.$row['nazwa'].'</td>';
  12. $display_string .= '<td>'.$row['cena'].'</td>';
  13. $display_string .= '</tr>';
  14.  
  15. }
  16. $display_string .= '</table>';
  17. echo $display_string;
  18. ?>


Nadmienię, że wszystko chodzi poprawnie, więc nie rozumiem skąd ten problem. Główka tabeli (th) "łapie kolor", ale co drugi wiersz już tego nie chce:(
Czy ktoś mi pomoże wskazując błąd

Ten post edytował marcwars 29.11.2011, 22:07:58
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: 3.10.2025 - 18:42