01. juni 2003 - 21:31
Der er
15 kommentarer og 1 løsning
Første linje anden farve
Hejsa Jeg skriver nogle poster ud fra en databasen. Men den første post skal skrives med rød, resten skal der ikke gøre noget ved. Hvordan gør jeg det?
Annonceindlæg fra Deloitte
Eks: do while not rs.EOF if forstePost <> true then Response.write "<font color=red>" Response.write "<td>" & rs("kolonne1") & "</td>" Response.write "<td>" & rs("kolonne2") & "</td>" if forstePost <> true then Response.write "</font>" forstePost = true end if rs.Movenext loop
Min kode ser sådan ud. Hvordan får jeg så det ind i? <% if not rs.bof and not rs.eof then%> <%do while not RS.eof a=a+1 %> <TD class=copy align=center width=15 bgColor=#FFFFFF height=21><b><% response.write a%></b></TD> <TD class=copy width=180 bgColor=#FFFFFF height="21"><SPAN style="FLOAT: left"><%=rs("holdnavn")%></SPAN> </TD> <TD class=copy width="20" height="21"><%=rs("felt1")%></TD> <TD class=copy width="20" height="21"><%=rs("felt2")%></TD> <TD class=copy width="20" height="21"><%=rs("felt3")%></TD> <TD class=copy width="20" height="21"><%=rs("felt4")%></TD> <TD class=copy height="21"><%=rs("felt5")%></TD> <TD class=copy bgColor=#EEEEEE width="30" height="21"><b><%=rs("felt6")%></b></TD></TR> <TR> <% RS.movenext loop end if %>
Det er teksten som skal være rød?
ja nemlig, på alle 6 felter.
Ok så prøv sådan her: <% if not rs.bof and not rs.eof then%> <%do while not RS.eof if forstePost <> true then Response.write "<font color=red>" a=a+1 %> <TD class=copy align=center width=15 bgColor=#FFFFFF height=21><b><% response.write a%></b></TD> <TD class=copy width=180 bgColor=#FFFFFF height="21"><SPAN style="FLOAT: left"><%=rs("holdnavn")%></SPAN> </TD> <TD class=copy width="20" height="21"><%=rs("felt1")%></TD> <TD class=copy width="20" height="21"><%=rs("felt2")%></TD> <TD class=copy width="20" height="21"><%=rs("felt3")%></TD> <TD class=copy width="20" height="21"><%=rs("felt4")%></TD> <TD class=copy height="21"><%=rs("felt5")%></TD> <TD class=copy bgColor=#EEEEEE width="30" height="21"><b><%=rs("felt6")%></b></TD></TR> <TR> <% if forstePost <> true then Response.write "</font>" forstePost = true end if RS.movenext loop end if %>
Det virker desværre ikke. Teksten bliver stadig ikke rød.
hmm nej det virker ikke uden om kolonnerne .. Så prøv med dette: <% if not rs.bof and not rs.eof then%> <%do while not RS.eof if forstePost <> true then strColor = "red" forstePost = true else strColor = "none" end if a=a+1 %> <TD class=copy align=center width=15 bgColor=#FFFFFF height=21><font color=<%=strColor%>><b><% response.write a%></b></font></TD> <TD class=copy width=180 bgColor=#FFFFFF height="21"><SPAN style="FLOAT: left"><font color=<%=strColor%>><%=rs("holdnavn")%></font></SPAN> </TD> <TD class=copy width="20" height="21"><font color=<%=strColor%>><%=rs("felt1")%></font></TD> <TD class=copy width="20" height="21"><font color=<%=strColor%>><%=rs("felt2")%></font></TD> <TD class=copy width="20" height="21"><font color=<%=strColor%>><%=rs("felt3")%></font></TD> <TD class=copy width="20" height="21"><font color=<%=strColor%>><%=rs("felt4")%></font></TD> <TD class=copy height="21"><font color=<%=strColor%>><%=rs("felt5")%></font></TD> <TD class=copy bgColor=#EEEEEE width="30" height="21"><b><font color=<%=strColor%>><%=rs("felt6")%></font></b></TD></TR> <TR> <% RS.movenext loop end if %>
Nu er det bare perfekt. Mange tak for hjælpen, det er dejligt at nogen gider at hjælpe.
Et lille ekstra spørgsmål hvis du gider: Er det også muligt at gøre den første linje fed?
01. juni 2003 - 22:27
#10
Ja så det nok lettere sådan her, da fed giver en tag på hver side af teksten: <% if not rs.bof and not rs.eof then%> <%do while not RS.eof a=a+1 %> <TD class=copy align=center width=15 bgColor=#FFFFFF height=21> <% if forstePost <> true then Response.write "<font color=red><b>" %><b><% response.write a%></b> <% if forstePost <> true then Response.write "</font></b>" %> </TD> <TD class=copy width=180 bgColor=#FFFFFF height="21"><SPAN style="FLOAT: left"> <% if forstePost <> true then Response.write "<font color=red><b>" %> <%=rs("holdnavn")%></SPAN> <% if forstePost <> true then Response.write "</font></b>" %></TD> <TD class=copy width="20" height="21"> <% if forstePost <> true then Response.write "<font color=red><b>" %><%=rs("felt1")%> <% if forstePost <> true then Response.write "</font></b>" %></TD> <TD class=copy width="20" height="21"> <% if forstePost <> true then Response.write "<font color=red><b>" %><%=rs("felt2")%> <% if forstePost <> true then Response.write "</font></b>" %></TD> <TD class=copy width="20" height="21"> <% if forstePost <> true then Response.write "<font color=red><b>" %><%=rs("felt3")%> <% if forstePost <> true then Response.write "</font></b>" %></TD> <TD class=copy width="20" height="21"> <% if forstePost <> true then Response.write "<font color=red><b>" %> <%=rs("felt4")%> <% if forstePost <> true then Response.write "</font></b>" %></TD> <TD class=copy height="21"> <% if forstePost <> true then Response.write "<font color=red><b>" %><%=rs("felt5")%> <% if forstePost <> true then Response.write "</font></b>" %></TD> <TD class=copy bgColor=#EEEEEE width="30" height="21"><b> <% if forstePost <> true then Response.write "<font color=red><b>" %><%=rs("felt6")%></b> <% if forstePost <> true then Response.write "</font></b>" %></TD></TR> <TR> <% forstePost = true RS.movenext loop end if %>
02. juni 2003 - 02:18
#12
>>eagleeye hvad med at have en class til at styre det -- bliver koden ikke en anelse pænere ;O)
02. juni 2003 - 17:45
#13
Jeps i stil med dette...: <head> <style> .forste { FONT-WEIGHT: bolder; COLOR: red }; .andre { }; </style> </head> <% if not rs.bof and not rs.eof then%> <%do while not RS.eof if forstePost <> true then strClass = "forste" forstePost = true else strClass = "andre" end if a=a+1 %> <TD class=copy align=center width=15 bgColor=#FFFFFF height=21><font class=<%=strClass%>><b><% response.write a%></b></font></TD> <TD class=copy width=180 bgColor=#FFFFFF height="21"><SPAN style="FLOAT: left"><font class=<%=strClass %>><%=rs("holdnavn")%></font></SPAN> </TD> <TD class=copy width="20" height="21"><font class=<%=strClass %>><%=rs("felt1")%></font></TD> <TD class=copy width="20" height="21"><font class=<%=strClass %>><%=rs("felt2")%></font></TD> <TD class=copy width="20" height="21"><font class=<%=strClass %>><%=rs("felt3")%></font></TD> <TD class=copy width="20" height="21"><font class=<%=strClass %>><%=rs("felt4")%></font></TD> <TD class=copy height="21"><font class=<%=strClass %>><%=rs("felt5")%></font></TD> <TD class=copy bgColor=#EEEEEE width="30" height="21"><b><font class=<%=strClass %>><%=rs("felt6")%></font></b></TD></TR> <TR> <% RS.movenext loop end if %>
02. juni 2003 - 23:52
#14
Mange tak for det. Det blev det oså lidt pænere af ja :-)
03. juni 2003 - 01:13
#15
;O)
03. juni 2003 - 01:41
#16
Jeg ville nu godt nok have tænkt denne vej: <head> <style> .forste { FONT-WEIGHT: bolder; COLOR: red }; .copy {color:#000 }; </style> </head> <% if not rs.bof and not rs.eof then%> <%do while not RS.eof if forstePost <> true then strClass = "forste" forstePost = true else strClass = "copy" end if a=a+1 %> <TD class=<%=strClass%> align=center width=15 bgColor=#FFFFFF height=21><b><% response.write a%></b></TD> <TD class=<%=strClass%> width=180 bgColor=#FFFFFF height="21"><SPAN style="FLOAT: left"><%=rs("holdnavn")%></SPAN> </TD> <TD class=<%=strClass%> width="20" height="21"><%=rs("felt1")%></TD> <TD class=<%=strClass%> width="20" height="21"><%=rs("felt2")%></TD> <TD class=<%=strClass%> width="20" height="21"><%=rs("felt3")%></TD> <TD class=<%=strClass%> width="20" height="21"><%=rs("felt4")%></TD> <TD class=<%=strClass%> height="21"><%=rs("felt5")%></TD> <TD class=<%=strClass%> bgColor=#EEEEEE width="30" height="21"><b><%=rs("felt6")%></b></TD></TR> <TR> <% RS.movenext loop end if %> hth jes
Kurser inden for grundlæggende programmering