| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Automatically changing td background color depending on content
Hi all,
I have a drop down menu where I select a name to view results of a test. The answers can be 0,1,2, or 3 in the fields where they are called. I'm wondering how I can go about getting the background to change color depending on the values stored. For example if it is a 1 I would like the background to be red, if it is a 2 I would like it to be blue, etc. Here is a sample of the code I use to call the values from the sql databse. Thanks in advance for any help offered. <td height=13 class=xl27 style='height:9.75pt;border-top:none'>Title</td> <td class=xl27 style='border-top:none;border-left:none'> <div align="center"> <% Response.Write RS("A_K1")%></div></td> <td class=xl27 style='border-top:none;border-left:none'> <div align="center"> <% Response.Write RS("A_P1")%></div></td> <td colspan=2 class=xl52 style='border-right:.5pt solid black;border-left: none'><div align="center"> <% Response.Write RS("B_K2")%></div></td> <td class=xl27 style='border-top:none;border-left:none'> <div align="center"> <% Response.Write RS("B_P2")%></div></td> <td class=xl27 style='border-top:none;border-left:none'> |
|
#2
|
|||
|
|||
|
I have made it work..well kind of. This is what I have
<% if RS("A_K1") = "1" then %> <td bgcolor="#996699" class=xl27 style='border-top:none;border-left:none'> <div align="center"> <% Response.Write RS("A_K1")%></div></td> <% else %> <td bgcolor="#33FF33" class=xl27 style='border-top:none;border-left:none'> <div align="center"> <% Response.Write RS("A_K1")%></div></td> <% end if %> but I need more than 2 options. I have 3 different numbers to color. I'm not sure of what if then else statement I can use, everything I try doesn't work. Any ideas? Thanks. |
|
#3
|
||||
|
||||
|
Try using if elseif statements
Code:
if crit = 1 then -->change bg elseif crit = 2 then -->change bg elseif crit = 3 then -->change bg end if hope this helps. |
|
#4
|
|||
|
|||
|
I finally worked it out. Thanks for yor response! Seems so easy now... this programming stuff makes my head hurt hehe.
|
|
#5
|
||||
|
||||
|
Glad you got it working,
I think we all get a headache from programming every now and then . |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Automatically changing td background color depending on content |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|