09. juli 2008 - 09:22Der er
3 kommentarer og 1 løsning
Tabell, endre farge på annenhver linje
Jeg ønsker å ha forskjellig farge på annenhver linje i tabellen min. Alternating row colors altså.
Her er koden min:
<% Set MyConn = Server.CreateObject("ADODB.Connection") MyConn.Open "DSN=*;UID=*;PWD=*" SQL_query = "SELECT * FROM RESSURSER WHERE PersonID = '" & Session("USER_LOGIN") &"' OR Gruppe = '1'" Set RS2 = MyConn.Execute(SQL_query) Dim lngColumnCount lngColumnCount=0 if not RS2.EOF then Response.Write "<tr>" Do while not RS2.EOF %> <td width="50%" align="left" valign="top"><a href="<%=RS2("URL")%>" target="_blank"><span class="style2"><%=RS2("TEKST")%></span></a></td> <% lngColumnCount=lngColumnCount+1 if lngColumnCount=2 then Response.Write "</tr><tr>" lngColumnCount=0 end if RS2.MoveNext Loop // Response.Write "<td colspan=" & 2-lngColumnCount & "> </td></tr>" end if RS2.Close %>
<% Set MyConn = Server.CreateObject("ADODB.Connection") MyConn.Open "DSN=*;UID=*;PWD=*" SQL_query = "SELECT * FROM RESSURSER WHERE PersonID = '" & Session("USER_LOGIN") &"' OR Gruppe = '1'" Set RS2 = MyConn.Execute(SQL_query) Dim lngColumnCount lngColumnCount=0 if not RS2.EOF then a=1 Response.Write "<tr>" Do while not RS2.EOF if a=1 then a=0 %> <td width="50%" align="left" valign="top"><a href="<%=RS2("URL")%>" target="_blank"><span class="style2"><%=RS2("TEKST")%></span></a></td> <% else a=1 %> <td width="50%" align="left" valign="top" bgcolor="#eeeeee"><a href="<%=RS2("URL")%>" target="_blank"><span class="style2"><%=RS2("TEKST")%></span></a></td> <% end if
lngColumnCount=lngColumnCount+1 if lngColumnCount=2 then Response.Write "</tr><tr>" lngColumnCount=0 end if RS2.MoveNext Loop // Response.Write "<td colspan=" & 2-lngColumnCount & "> </td></tr>" end if RS2.Close %>
counter = 0 do while not RS2.EOF if counter mod 4 >= 2 then %> <td width="50%" align="left" valign="top" bgcolor="#eeeeee"><a href="<%=RS2("URL")%>" target="_blank"><span class="style2"><%=RS2("TEKST")%></span></a></td> <%else <td width="50%" align="left" valign="top"><a href="<%=RS2("URL")%>" target="_blank"><span class="style2"><%=RS2("TEKST")%></span></a></td> <%end if %> <% lngColumnCount=lngColumnCount+1 if lngColumnCount=2 then Response.Write "</tr><tr>" lngColumnCount=0 end if counter = counter + 1 RS2.MoveNext Loop
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.