Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating TD BG Color

Status
Not open for further replies.

DANZIG

Technical User
Mar 8, 2001
142
US
Hellos,
I'm running a script that updates an sql sb every few seconds, I have an asp that runs a quesy and refreshes the web table based on the results. There are 10 fields in the result not all of them will have data abd they are populated left to right. I would like the empty <td bgcolor = ""> and the populated <td bgcolor = "gray">.

The Problem that I'm finding is that the bgcolor of each td element is not refreshed to display the result and new bgcolor based on the quey result and td population. I'm using <meta http-equiv="refresh" content="10"> to refresh the asp page. The asp is very simple:
Code:
If str_Online is null Then
  str_BG2 = " bgcolor=gray"
Else
  str_BG2 = ""
End If
Then the html is:
Code:
Response.Write"<tr><td width=90"&str_BG2&">Some Result&nbsp;</td></tr>

Any Ideas or am I going about this the wrong way?


Thanks, Danzig
 
A variable in ASP can't contain a NULL, only a zero-length (""). Try changing your code to

Code:
If str_Online = "" Then
  str_BG2 = " bgcolor=gray"
Else
  str_BG2 = ""
End If

Also, I think the color name has to be within quotes

Code:
If str_Online = "" Then
  str_BG2 = " bgcolor='gray'"
Else
  str_BG2 = ""
End If

But, some browsers do not interpret color names. All interpret color in hexidecimal form

[color]If str_Online = "" Then
str_BG2 = " bgcolor='#808080'"
Else
str_BG2 = ""
End If[/color]

Color hexidecimal quick reference -
 
Tried that one before but tried it again and doesn't seem to work. I've tried if len(str_online)<1 then also with no joy.


Thanks, Danzig
 
Maybe show us more f your code, like the SQl portions. It sounds like the problem is how your getting the data, not what your doing with it afterwards.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
What is the color being displayed - gray or not? If all fields are gray then it would seem str_Online is always empty.

Try writing str_Online and see what it contains. Assuming you update str_Online with each record as it is being written to the table and you run this code for each row (or field) in the recordset...

Code:
If str_Online = "" Then
  str_BG2 = " bgcolor='#808080'"
Else
  str_BG2 = ""
End If
[COLOR=red]Response.write str_Online[/color]

If there is nothin' in it, like Tarwn said, your problem is not with this part of your code.
 
It was a combination of having 's on the color and using len() but it is working now.



Thanks, Danzig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top