Forum Moderators: open

Message Too Old, No Replies

need to set a count on a td tag

need to set a count on a td tag

         

mavrick

2:20 pm on May 6, 2004 (gmt 0)

10+ Year Member



hi guys

I ran into a little bit of a problem.

i am writing from a db into a table on a webpage. the db can be updated, when items are added to the Db, the table expandeds.

i want to, when the table expands, store 3 td tags on one line and for the expanded bit to populate a line below it.

i am using a count to count the td tags, doesn't seem to work.

here is the code :

<%
count = 0
do while not rs.eof
count = count + 1
%>

<% If count = 0 then
Response.Write"<td width=""33%"">"
Response.Write"<p align=""center"">"
Response.Write"<b><font size=""2"" face=""Verdana"">"
Response.Write"<a href=""vehicle.asp?Vehicle="%>
<% =rs("vehicleCatID") %>
<%Response.Write""">"%><% =rs("vehicleCatName") %>
<%Response.Write"</a></font></b></td>"

ElseIf count = 2 then

Response.Write"<td width=""33%"">"
Response.Write"<p align=""center"">"
Response.Write"<b><font size=""2"" face=""Verdana"">"
Response.Write"<a href=""vehicle.asp?Vehicle="%><% =rs("vehicleCatID") %>
<% Response.Write" "">" %><% =rs("vehicleCatName")%>
<% Response.Write"</a></font></b></td>"%>

<%

End If
rs.movenext

loop
%>

Is there any other way to do this?
Somebody suggested the "mode" command or something like that. Can anybody tell me what this is?
thanks

Help!

WebJoe

3:16 pm on May 6, 2004 (gmt 0)

10+ Year Member



Mod
is the vb command for the function modulo, which results in the rest of a division (10 Mod 3 = 1)
You can use that to color every other line different:
If Count Mod 2 = 1

 response.write "<td bgcolor=""#000000"">

Else

 response.write "<td bgcolor=""#FFFFFF"">

End If

martyt

3:28 pm on May 6, 2004 (gmt 0)

10+ Year Member



Why don't you just use a datagrid control instead? It'll take care of all the formatting for you. You can customize the formatting as much as you want.

Lots of examples and help over on www.asp.net

Easy_Coder

4:35 pm on May 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your expecting to execute the if side of your routine, based on these 4 lines of code I don't see how (count) will ever have a value equal to 0 while executing the routine.


count = 0
do while not rs.eof
count = count + 1
If count = 0 then

I don't see anything in the routine that would ever set (count) back to 0. (count) = (count) + 1 ensures that (count) will never = 0 while in the loop.

This code...


ElseIf count = 2 then

will only fire once during execution of your routine.