Forums

This topic is locked

Dynamic Tables

Posted 30 Sep 2002 11:46:47
1
has voted
30 Sep 2002 11:46:47 Dave Thomas posted:
Hi,

Depending on a value in a recordset, is it possible to write the table cell background colour. for example:

If "win" is the value, bkgrd will be "green"
If "draw" is the value bkgrd will be "yellow"
If "lose" is the value bkgrd will be "red"



Regards,
Dave

UD4 || Flash || Access ||Web Hosting

Replies

Replied 30 Sep 2002 12:46:50
30 Sep 2002 12:46:50 Stuart Harland replied:
Yeah use a 'Select Case' for your condition:

Within your loop to display your data:

Select Case rs("Value"
 Case "Win"
  sColour = "green"
 Case "draw"
  sColour = "yellow"
 Case "lose"
  sColour = "red"
End Select

then in your table:

< td bgcolour="< % =sColour % >">

Hope it helps,
Stuart

********************
wheatNOTmeat
Replied 30 Sep 2002 12:49:28
30 Sep 2002 12:49:28 Vince Baker replied:
Using the code for If = win that you used before

Add another Dim as strBackColour
and amend your code to:

<% If strResult = "Win" Then strDisplayImage = "Win.jpg" And strBackColour= #cc3300 End IF %>

Then, in the background colour box in the properties section add this:

<%=strBackColour%>

Regards
Vince

Response.write("The best line of code you can ever use"

VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 30 Sep 2002 13:24:13
30 Sep 2002 13:24:13 Dave Thomas replied:
Na, Vince this one is for a seperate table, but the colours keep the consistency of the results.

One thing tho: What is the best position to insert the "<% Select Case ....%>"

Thanks chaps

Regards,
Dave

UD4 || Flash || Access ||Web Hosting


Edited by - UltraDav on 30 Sep 2002 13:25:36
Replied 01 Oct 2002 19:27:19
01 Oct 2002 19:27:19 Dave Thomas replied:
Okay had a go at that, and couldn't get it to work. Will only show the first colour.

I Tried first with the select case example, here was my code:

<%
Select Case rsClanA.fields.item("Result".value
Case "Win"
tdcolour="#00FF00"
Case "Draw"
tdcolor = "#FFFF00"
Case "Lose"
tdcolor ="#FF0000"
End Select
%>

Then

bgcolor=" <%= tdcolor %> " in my TD tag

As i said it colours the cell but only with the Win color "green", I've tried placing the code in the Repeat Region, Head, and Table Cell but with no joy.

I also tried it Vince's way using the IF statement, again this coloured the cell but only with Green. This is the final pice of the jigsaw for a certain part of the site and I really wanna sort it <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

I can send anyone the page if they would like to look at the source.

Regards,
Dave

UD4 || Flash || Access ||Web Hosting


Edited by - UltraDav on 01 Oct 2002 19:29:20

Reply to this topic