Text Color Based on DB Value | Bytes (2024)

Chris Stanley

I am using dreamweaver to make an ASP page. I have a table of data
from a MSSQL database that is currently showing on the ASP page. I
want the ability to change the color based on a priority number that's
in the MSSQL database (same recordset that the data comes from). I
don't have the priority field out on the page but can put it out if
need be. I have 3 different priority numbers and if the first row is
priority 1 I want the font to be red and if the second row is priority
2 I want the color to be yellow and so on.

Thanks

Chris

Jul 27 '05

Subscribe Reply

31 Text Color Based on DB Value | Bytes (1) 3095 Text Color Based on DB Value | Bytes (2)

  • <
  • 1
  • 2
  • 3
  • 4
  • >

Chris Hohmann

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:eU******** ******@tk2msftn gp13.phx.gbl...

I'm trying my best always to use CSS, but it gets my goat. Unless I'm
missing something, not ~every~ inline attribute has a CSS equivalent, and
that's frustrating!

Are you just going to leave us hanging like that!? :) What inline display
attribute is not represented in CSS? Also, which version of CSS are we
talking about 1, 2, 2.1, 3? Inquiring minds want to know.

Jul 27 '05 #11

Chris Stanley

OK, here's my code:

<html>
<head>
<title>Surry County E-911 Active Calls</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
<!--
-->
</style>
<style type="text/css">
<!--
-->
</style>
<meta http-equiv="Refresh" content="30">
</head>

<body bgcolor="#00000 0">
<div align="center">
<p><font color="#FFFFFF" size="7" face="Tahoma">S urry County E-911
Active Calls</font></p>
<p>&nbsp;</p>

<p><font color="#FF0000" > </MM:DECORATION></font></p>
<table width="97%" border="0" align="center">
<tr>
<td width="14%"><di v align="left"><f ont color="#FF0000" size="5"
face="Tahoma">C all
Number</font></div></td>
<td width="16%"><di v align="left"><f ont color="#FF0000" size="5"
face="Tahoma">C omplaint</font></div></td>
<td width="38%"><di v align="left"><f ont color="#FF0000" size="5"
face="Tahoma">I ncident
Location</font></div></td>
<td width="18%"><di v align="left"><f ont color="#FF0000" size="5"
face="Tahoma">C ity</font></div></td>
<td width="14%"><di v align="left"><f ont color="#FF0000" size="5"
face="Tahoma">
Unit</font></div></td>
</tr>
</table>
<hr>
<p>&nbsp;</p>
<MM_REPEATEDREG ION NAME="Repeat1" SOURCE="Records et1"><MM:DECORA TION
OUTLINE="Repeat " OUTLINEID=1>
<%
While ((Repeat1__numR ows <> 0) AND (NOT Recordset1.EOF) )
%>
<table width="97%" border="0" align="center">
<tr>
<td width="15%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Cal l_Number").Valu e)%></font></strong></font></td>
<td width="16%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Com plaint").Value) %></font></strong></font></td>
<td width="38%"><di v align="left"><f ont color="#00FFFF"
size="3"><stron g><font
face="Tahoma">< %=(Recordset1.F ields.Item("Act ual_Incid_Locat ion").Value)%> </font></strong></font></div></td>
<td width="18%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Act ual_Incid_City" ).Value)%></font></strong></font></td>
<td width="13%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Fir st_Unit").Value )%></font></strong></font></td>
</tr>
</table>
<%

Repeat1__index= Repeat1__index+ 1
Repeat1__numRow s=Repeat1__numR ows-1
Recordset1.Move Next()
Wend
%>
<font color="#FF0000" > </font>
<p>&nbsp;</p>
<p align="left"><f ont color="#FFFFFF" size="5" face="Tahoma">T otal
Active Calls:
<%=(Recordset1_ total)%></font></p>
<p align="left">&n bsp;</p>

</div>
</body>
</html>
<%
Recordset1.Clos e()
Set Recordset1 = Nothing
%>
Thanks

Chris

Jul 27 '05 #12

Ray Costanzo [MVP]

Well, in a way I spoke too soon. I guess I was thinking of cellpadding and
cellspacing, but I do understand that the padding and margin of the ~cells~
replace those! But what about something as basic AND COMMON as <table
align="center"> ?

I think what I'm most upset about is the fact that a span can't have a width
(strictly speaking). I hate that.

Ray at home

"Chris Hohmann" <no****@thankyo u.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:eU******** ******@tk2msftn gp13.phx.gbl...
I'm trying my best always to use CSS, but it gets my goat. Unless I'm
missing something, not ~every~ inline attribute has a CSS equivalent, and
that's frustrating!

Are you just going to leave us hanging like that!? :) What inline display
attribute is not represented in CSS? Also, which version of CSS are we
talking about 1, 2, 2.1, 3? Inquiring minds want to know.


Jul 28 '05 #13

Ray Costanzo [MVP]

I don't see anything that's an attempt to change colors. ?? I think your
first step would be to get rid of those <font> tags you have. How about:

<style type="text/css">
tr.priority1 { background-color: #ff0000; }
tr.priority2 { background-color: #ffff00; }
</style>

<table width="97%" border="0" align="center">
<tr class="priority <%=Recordset1.F ields.Item("Pri ority").Value%> ">
<td
width="15%"><%= (Recordset1.Fie lds.Item("Call_ Number").Value) %></td>
<td width="16%"><%= (Recordset1.Fie lds.Item("Compl aint").Value)%> </td>
<td
width="38%"><%= (Recordset1.Fie lds.Item("Actua l_Incid_Locatio n").Value)%> </td>
<td
width="18%"><%= (Recordset1.Fie lds.Item("Actua l_Incid_City"). Value)%></td>
<td width="13%"><%= (Recordset1.Fie lds.Item("First _Unit").Value)% ></td>
</tr>
</table>
I know this is easier said than done, but your first step actually ought to
be to stop using Dreamweaver for code writing. If you want to use it for
design, that's one thing, but it shouldn't be used for ASP code, imo.

Ray at home

"Chris Stanley" <ch**********@g mail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .

<MM_REPEATEDREG ION NAME="Repeat1" SOURCE="Records et1"><MM:DECORA TION
OUTLINE="Repeat " OUTLINEID=1>
<%
While ((Repeat1__numR ows <> 0) AND (NOT Recordset1.EOF) )
%>
<table width="97%" border="0" align="center">
<tr>
<td width="15%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Cal l_Number").Valu e)%></font></strong></font></td>
<td width="16%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Com plaint").Value) %></font></strong></font></td>
<td width="38%"><di v align="left"><f ont color="#00FFFF"
size="3"><stron g><font
face="Tahoma">< %=(Recordset1.F ields.Item("Act ual_Incid_Locat ion").Value)%> </font></strong></font></div></td>
<td width="18%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Act ual_Incid_City" ).Value)%></font></strong></font></td>
<td width="13%"><fo nt color="#00FFFF" ><strong><fon t size="3"
face="Tahoma">< %=(Recordset1.F ields.Item("Fir st_Unit").Value )%></font></strong></font></td>
</tr>
</table>
<%

Repeat1__index= Repeat1__index+ 1
Repeat1__numRow s=Repeat1__numR ows-1
Recordset1.Move Next()
Wend
%>
<font color="#FF0000" > </font>
<p>&nbsp;</p>
<p align="left"><f ont color="#FFFFFF" size="5" face="Tahoma">T otal
Active Calls:
<%=(Recordset1_ total)%></font></p>
<p align="left">&n bsp;</p>

Jul 28 '05 #14

Adrienne

Gazing into my crystal ball I observed "Ray Costanzo [MVP]" <my first
name at lane 34 dot commercial> writing in
news:#v******** ******@TK2MSFTN GP12.phx.gbl:

Well, in a way I spoke too soon. I guess I was thinking of cellpadding
and cellspacing, but I do understand that the padding and margin of the
~cells~ replace those! But what about something as basic AND COMMON as
<table align="center"> ?
table {text-align:center} /*centers the table content */
table {margin-left:auto; margin-right:auto; width:whatever} /* centers the
~table~ in the viewport*/

I think what I'm most upset about is the fact that a span can't have a
width (strictly speaking).
Span is an inline element, you really wouldn't want it to have width. But,
you can always use display:block and then set a width. There is also
display:table-inline, etc., but these some of these are not supported by
our favorite browser. I very rarely use span, I usually style the element.
I hate that.
What I really hate is max and min width not supported by IE, position:fixed
not supported by IE, hover pseudo class only working for the A element in
IE, alpha transparency in PNGs not supported by IE. If I could, I would go
to everyone's Windows computer, remove IE, and replace it with Opera or
Firefox.

Ray at home

"Chris Hohmann" <no****@thankyo u.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote
in message news:eU******** ******@tk2msftn gp13.phx.gbl...
I'm trying my best always to use CSS, but it gets my goat. Unless
I'm missing something, not ~every~ inline attribute has a CSS
equivalent, and that's frustrating!

Are you just going to leave us hanging like that!? :) What inline
display attribute is not represented in CSS? Also, which version of
CSS are we talking about 1, 2, 2.1, 3? Inquiring minds want to know.


--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Jul 28 '05 #15

Chris Stanley

That did it. Thanks for the help.

Chris

Jul 28 '05 #16

Ray Costanzo [MVP]

"Adrienne" <ar********@sbc global.net> wrote in message
news:Xn******** *************** *****@207.115.6 3.158...

table {text-align:center} /*centers the table content */
table {margin-left:auto; margin-right:auto; width:whatever} /* centers the
~table~ in the viewport*/
The margin one is the work-around that I would typically use, but then I
decide that it just makes 100 times more sense to stop being so absolute and
just use the inline align="center" attribute, as much as I hate to do it.

I think what I'm most upset about is the fact that a span can't have a
width (strictly speaking).
Span is an inline element, you really wouldn't want it to have width.

But, you can always use display:block and then set a width. There is also
display:table-inline, etc., but these some of these are not supported by
our favorite browser. I very rarely use span, I usually style theelement.

I understand why the span doesn't have a width, but I disagree with it. And
as far as the display:block, that kinda defeats the purpose of the span.
Also, if you want to get technical, I want to say that as soon as you do a
display:inline to a block element like a table, that will void any width
styles in strict browsers. 8[

I hate that.
What I really hate is max and min width not supported by IE,

position:fixed not supported by IE, hover pseudo class only working for the A element in
IE, alpha transparency in PNGs not supported by IE. If I could, I wouldgo to everyone's Windows computer, remove IE, and replace it with Opera or
Firefox.

I'm just going to start writing console applications. :]

Rya at work

Jul 28 '05 #17

Chris Hohmann

"Adrienne" <ar********@sbc global.net> wrote in message
news:Xn******** *************** *****@207.115.6 3.158...

What I really hate is max and min width not supported by IE,
position:fixed
not supported by IE, hover pseudo class only working for the A element in
IE, alpha transparency in PNGs not supported by IE. If I could, I would
go
to everyone's Windows computer, remove IE, and replace it with Opera or
Firefox.

Amen to that! Just give us hover pseudo class support for lists and I'd be
satisfied. We could then do away with JavaScript menus altogether. Hopefully
the powers that be are listening. :) Here's a CSS/DHTML hybrid that uses
behaviors to add support for Internet Explorer, if anyone is interested.

http://www.brothercake.com/scripts/navmeister/page.php

Jul 28 '05 #18

Aaron Bertrand [SQL Server MVP]

> I understand why the span doesn't have a width, but I disagree with it.

If it's a <div> then use a <div>. A span is contained within another
element that has some kind of defined width. If you need to define widths
inside that way, then as much as I hate to suggest it, I would say use a
table instead (or the very complex kind of CSS that properly replicates a
table, but in a much more cumbersome fashion).

Jul 28 '05 #19

Dave Anderson

Ray Costanzo [MVP] wrote:

I'm trying my best always to use CSS, but it gets my goat.
Unless I'm missing something, not ~every~ inline attribute
has a CSS equivalent, and that's frustrating!

This is perhaps my single biggest gripe with Internet Explorer's stagnation.
There are many CSS features already implemented in other browsers that IE
still does not understand. And that effectively renders them nonexistent
unless authors are willing to ignore IE users.

The blame for your frustration regarding CSS, then, lies squarely with
Microsoft, not with CSS itself.
--
Dave Anderson, hoping Roland is reading

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 28 '05 #20

  • <
  • 1
  • 2
  • 3
  • 4
  • >

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6 148548

Show/Hide text and form field based on drop down selection

by: Steve Speirs |last post by:

Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected value="">Please make a selection</option> <option value="1">Choice 1</option> <option value="2">Choice 2</option> <option value="3">Choice 3</option>

Javascript

4 3402

Is it possible to have rewrite html formatted text from a button click in javascript?

by: frogman042 |last post by:

My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document write and it works fine until she puts it into a function and then calls the function from a button with onClick. This also seems to work OK, with the...

Javascript

5 2694

QUERY BASED ON TEXT BOX

by: RICHARD BROMBERG |last post by:

I am using MS Access 2000 and crating an application where the main table has about 90 fields. I understand how to run a where the value of a PARTICULAR field is entered into a text box. I want to allow the user to enter the FIELD into one text box and the CRITERIA into another text box and then run a query based on the values entered. ...

Microsoft Access / VBA

2 4790

Display suggested completion for text box input. How?

by: Corepaul |last post by:

As input is typed into a text box, I would like to search a recordset for the first record that matches what has been typed so far. I would like to update the text box to display the letters typed by the user in the normal font and any additional characters in the first matching record displayed as highlighted text. This matches the action of...

Microsoft Access / VBA

5 18251

Count in a Text Box Control Source Property

by: Cro |last post by:

Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to display the number of times a certain value appears in a certain field (i.e. perform a ‘count'). I will be doing this for many values in many...

Microsoft Access / VBA

14 2237

How to accumulate text in a combobox?

by: Norm |last post by:

Hi, Each time the user selects an item from a combobox, I want that string to get appended to the values that were already selected. The result is that the combo is accumulating text each time the user selects an item from its list. I want the delete and backspace keys to function normally, as well as all the other properties of the...

Microsoft Access / VBA

8 18328

Initial Value for Combo Box Text field

by: Lyn |last post by:

Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". The values in the dropdown are loaded in the correct order, but the initial value is not the first row of the dropdown as I expected. The field...

Microsoft Access / VBA

1 4087

Showing XHTML text in Word 2007 with the formatting via webservices

by: Darsin |last post by:

What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS. The Web Services are explained as follows: IMPORT WEB SERVICE:

.NET Framework

16 5131

Why can't I set the textbox "text" property??

by: mj.redfox.mj |last post by:

Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString Page.FindControl("tdInput").Controls.Add(txtTest) This successfully creates a textbox called "txtLeft1" in the table

ASP.NET

1 4186

by: littlealex |last post by:

IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? ...

HTML / CSS

7799

What is ONU?

by: marktang |last post by:

ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...

General

7716

Changing the language in Windows 10

by: Hystou |last post by:

Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...

Windows Server

8226

Maximizing Business Potential: The Nexus of Website Design and Digital Marketing

by: jinu1996 |last post by:

In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...

Online Marketing

1 5612

Access Europe - Using VBA to create a class based on a table - Wed 1 May

by: isladogs |last post by:

The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...

Microsoft Access / VBA

5297

Couldn’t get equations in html when convert word .docx file to html file in C#.

by: conductexam |last post by:

I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...

C# / C Sharp

3748

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 2235

transfer the data from one system to another through ip address

by: 6302768590 |last post by:

Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

C# / C Sharp

1 1333

How to add payments to a PHP MySQL app.

by: muto222 |last post by:

How can i add a mobile payment intergratation into php mysql website.

PHP

1053

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

by: bsmnconsultancy |last post by:

In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

General

Text Color Based on DB Value | Bytes (2024)
Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6253

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.