Forums
This topic is locked
Change table cell color based on value in cell
18 Oct 2001 20:23:33 B. B. posted:
Hello! Have a table displayed using the repeat region behavior on a page. Would like to change the cell color or at least bold the cell text if the value in a cell is OUT and this value can only occur in one column of a row which contains about 20 columns.
Is there a way to code an if statement or the like within the <td> and check for the value then set the bgcolor to some color? Have heard references to a conditional region behavior but not sure of all the functions it can perform.
Would greatly appreciate any help or references concerning this. Thanks!
Replies
Replied 19 Oct 2001 13:25:44
19 Oct 2001 13:25:44 Owen Eastwick replied:
Try Something like this:
<pre id=code><font face=courier size=2 id=code>
<% If (YourRecordsetNAme.Fields.Item("FieldName".Value) = "WhateverYouWant" Then%><td width="50" bgcolor="#FF6600"><% Else %><td width="50" bgcolor="#C0C0C0"><% End If %>
</font id=code></pre id=code>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
<pre id=code><font face=courier size=2 id=code>
<% If (YourRecordsetNAme.Fields.Item("FieldName".Value) = "WhateverYouWant" Then%><td width="50" bgcolor="#FF6600"><% Else %><td width="50" bgcolor="#C0C0C0"><% End If %>
</font id=code></pre id=code>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 22 Oct 2001 09:56:43
22 Oct 2001 09:56:43 B. B. replied:
Hey Owen! The example code worked nicely.
The Design View looks a little off since the table column headings do not match with all the table detail values now. Have two td tag entries for each column now based on the If or the Else condition.
However, the results are correct which is changing the background cell color.
Very much appreciate the great help. Thanks!
The Design View looks a little off since the table column headings do not match with all the table detail values now. Have two td tag entries for each column now based on the If or the Else condition.
However, the results are correct which is changing the background cell color.
Very much appreciate the great help. Thanks!
Replied 24 Oct 2001 12:11:55
24 Oct 2001 12:11:55 B. B. replied:
Hey Owen! Have one more quick question about this.
How would you code a compound if for the same table cell and have the background changed to a different color.
For example, currently check in the table cell if the rs.value=OUT then set bgcolor to red but want to add an OR condition.
The new IF would be something like IF rs.value=OUT then bgcolor=red OR IF rs.value=IN then bgcolor=green for this cell in the table.
One more too, was trying to paste the code in this post but it did not display the code in the percent signs and it also resolved the html table tags. How do you make it so that it will post as comments and not try to resolve the tags?
Have tried the insert code image but that did not work. Thanks!
How would you code a compound if for the same table cell and have the background changed to a different color.
For example, currently check in the table cell if the rs.value=OUT then set bgcolor to red but want to add an OR condition.
The new IF would be something like IF rs.value=OUT then bgcolor=red OR IF rs.value=IN then bgcolor=green for this cell in the table.
One more too, was trying to paste the code in this post but it did not display the code in the percent signs and it also resolved the html table tags. How do you make it so that it will post as comments and not try to resolve the tags?
Have tried the insert code image but that did not work. Thanks!
Replied 25 Oct 2001 03:00:59
25 Oct 2001 03:00:59 Owen Eastwick replied:
To make the table cell different colours:
<pre id=code><font face=courier size=2 id=code>
<% If (YourRecordsetNAme.Fields.Item("FieldName".Value) = "IN" Then%>
<td width="50" bgcolor="#FF6600">
<% If (YourRecordsetNAme.Fields.Item("FieldName".Value) = "OUT" Then%>
<td width="50" bgcolor="#0000cc">
<% Else %>
<td width="50" bgcolor="#C0C0C0">
<% End If %>
</font id=code></pre id=code>
To display code on the forum click the <b>#</b> then paste your code between the code tags. Begin code tag [ code ], End Code Tag [ /code ] (I've added the spaces so you can see it).
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
<pre id=code><font face=courier size=2 id=code>
<% If (YourRecordsetNAme.Fields.Item("FieldName".Value) = "IN" Then%>
<td width="50" bgcolor="#FF6600">
<% If (YourRecordsetNAme.Fields.Item("FieldName".Value) = "OUT" Then%>
<td width="50" bgcolor="#0000cc">
<% Else %>
<td width="50" bgcolor="#C0C0C0">
<% End If %>
</font id=code></pre id=code>
To display code on the forum click the <b>#</b> then paste your code between the code tags. Begin code tag [ code ], End Code Tag [ /code ] (I've added the spaces so you can see it).
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo