Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Knowledge Base Q

Status
Not open for further replies.

Corneliu

Technical User
Sep 16, 2002
141
US
I am building a new Knowledge Base system and I have one question. The database works great and no issues, but when I get the list of questions, I would like to show the user with a different color every other result. For Example, the knowledge base for Windows has 10 questions. Well, I would like it when returned from the database to show first line gray, second line white, third line gray, etc etc etc. Kind of like this here.
Is there in any way I can do the same? Otherwise when you return the records, each record looks the same color and looks boring. Anyone know how to do this? This is my code:

<%
while not RS.EOF
%>
<table width=&quot;800&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;RecsList&quot;>
<!--DWLayoutTable-->
<tr>
<td width=&quot;660&quot; valign=&quot;top&quot; bgcolor=&quot;#666666&quot;><font color=&quot;#FFFF00&quot; size=&quot;3&quot;><strong><em><font size=&quot;1&quot;>Q:</font></em></strong></font><font color=&quot;#FFFFFF&quot; size=&quot;1&quot;>&nbsp;
</font><font color=&quot;#FFFFFF&quot;><%=RS(&quot;Problem&quot;) %> </font></td>
<td width=&quot;140&quot; valign=&quot;top&quot; bgcolor=&quot;#666666&quot;>
<div align=&quot;right&quot;><font color=&quot;#FFFFFF&quot;>Date Of: <%=RS(&quot;KDate&quot;) %></font> </div></td>
</tr>
</table>
<%
' This is the loop command. It calls for the next record
RS.MoveNext
WEND
%>

Thankx for your help.
 
<%
dim bgColor
while not RS.EOF
IF bgColor = &quot;silver&quot; THEN bgColor = &quot;white&quot; else bgColor = &quot;silver&quot;
%>
<table width=&quot;800&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;RecsList&quot; bgColor=&quot;<%=bgColor%>&quot;>
<!--DWLayoutTable-->
<tr>
<td width=&quot;660&quot; valign=&quot;top&quot; bgcolor=&quot;#666666&quot;><font color=&quot;#FFFF00&quot; size=&quot;3&quot;><strong><em><font size=&quot;1&quot;>Q:</font></em></strong></font><font color=&quot;#FFFFFF&quot; size=&quot;1&quot;>
</font><font color=&quot;#FFFFFF&quot;><%=RS(&quot;Problem&quot;) %> </font></td>
<td width=&quot;140&quot; valign=&quot;top&quot; bgcolor=&quot;#666666&quot;>
<div align=&quot;right&quot;><font color=&quot;#FFFFFF&quot;>Date Of: <%=RS(&quot;KDate&quot;) %></font> </div></td>
</tr>
</table>
<%
' This is the loop command. It calls for the next record
RS.MoveNext
WEND
%>


I usually use this method on individaul rows w/in a table - but it can work on whole tables also. Of course any DHTML that you have will take precedence over this. You could use the same method to write two different class names for the tables and have two definitions in your style sheets...
 
what you can do is changing your code this way (in green is ASP code) :

<table width=&quot;800&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;RecsList&quot;>
<COL width=&quot;660px&quot;>
<COL WIDTH=&quot;140px&quot;>
<TBODY>

<%
const WHITE=&quot;#FFFFFF&quot;
const GRAY=&quot;#666666&quot;
Dim grayLine
Dim TdTag

GrayLine=false

while not RS.EOF
if GrayLine then
TdTag=&quot;<td valign='top' bgcolor=' & GRAY & &quot;'>&quot;
GrayLine = false
else
TdTag=&quot;<td valign='top' bgcolor=' & WHITE & &quot;'>&quot;
GrayLine = true
end if
%>

<!--DWLayoutTable-->
<tr>
<%=TdTag%>
<font color=&quot;#FFFF00&quot; size=&quot;3&quot;><strong><em><font size=&quot;1&quot;>Q:</font></em></strong></font><font color=&quot;#FFFFFF&quot; size=&quot;1&quot;>
</font><font color=&quot;#FFFFFF&quot;><%=RS(&quot;Problem&quot;) %> </font>
</td>
<%=TdTag%>
<div align=&quot;right&quot;><font color=&quot;#FFFFFF&quot;>Date Of: <%=RS(&quot;KDate&quot;) %></font> </div>
</td>
</tr>
<%
RS.MoveNext
WEND
%>
</TBODY>
</table>
Water is not bad as soon as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top