The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Is there a way to change the background color on tables?
Aruban
post Nov 2 2006, 06:01 PM
Post #1


Newbie
*

Group: Members
Posts: 12
Joined: 25-October 06
Member No.: 565



I want to be able to change the background color of specific cells in a table as opposed to changing every cell in the table. Is there a way to do this?

Thanks.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 2 2006, 06:08 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Sure, with the bgcolor attribute.
http://www.htmlhelp.com/reference/html40/tables/td.html
It's better done with CSS though.
http://www.htmlhelp.com/reference/css/colo...ound-color.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Aruban
post Nov 2 2006, 06:10 PM
Post #3


Newbie
*

Group: Members
Posts: 12
Joined: 25-October 06
Member No.: 565



Sorry. I asked the wrong question. What I meant to ask was:

Is there a way to change a cell's background color based upon the variable within that cell?

Thanks.


QUOTE(pandy @ Nov 2 2006, 06:08 PM) *

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 2 2006, 06:15 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Variable? blink.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Aruban
post Nov 2 2006, 06:18 PM
Post #5


Newbie
*

Group: Members
Posts: 12
Joined: 25-October 06
Member No.: 565



I have a form users are filling out. When completed and submit button is pressed, all the information is reprocessed onto a handling page....it's reformatted using tables. I want certain cells in the tables to change background colors based upon the users input in that category.


QUOTE(pandy @ Nov 2 2006, 06:15 PM) *

Variable? blink.gif

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Nov 2 2006, 06:24 PM
Post #6


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



The cleanest way is to use CSS classes, and to have the server-side program that is processing the form data to assign classes based on the input. Something like

if (value == "apple") then print "<td class='redfruit'>"
if (value == "orange") then print "<td class='orangefruit'>"
if (value == "banana" || value == "lemon") then print "<td class='yellowfruit'>"
...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Aruban
post Nov 2 2006, 06:27 PM
Post #7


Newbie
*

Group: Members
Posts: 12
Joined: 25-October 06
Member No.: 565



Thanks Darin. The other thing I noticed as I was experimenting with background colors in tables is that, if I print the html file, the colors don't show up. It's all black and white. I double-checked my print settings, which are set for color. Any thoughts?


QUOTE(Darin McGrew @ Nov 2 2006, 06:24 PM) *

The cleanest way is to use CSS classes, and to have the server-side program that is processing the form data to assign classes based on the input. Something like

if (value == "apple") then print "<td class='redfruit'>"
if (value == "orange") then print "<td class='orangefruit'>"
if (value == "banana" || value == "lemon") then print "<td class='yellowfruit'>"
...

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Nov 2 2006, 06:50 PM
Post #8


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(Aruban @ Nov 2 2006, 03:27 PM) *
The other thing I noticed as I was experimenting with background colors in tables is that, if I print the html file, the colors don't show up. It's all black and white. I double-checked my print settings, which are set for color. Any thoughts?
I've seen this kind of thing when the style sheet is specified for media="screen" rather than media="screen,print". The article Going to Print discusses print style sheets as a positive thing, but the flip side is that if you specify style sheets for screen only, then they won't apply when the page is printed.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 12:44 AM