473,804 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text Color Based on DB Value

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 #1
31 3114
col = rs("priority")
if col = 1 then
fontcolor = "#FF0000"
elseif col = 2 then
fontcolor = "#FFFF00"
end if
response.write "<span style='color:" & fontcolor & "'>" & stuff & "</span>"

"Chris Stanley" <ch**********@g mail.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
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 #2
Thanks for the quick response. Is there a certain place I need to put
this code???

Chris

Jul 27 '05 #3

"Chris Stanley" <ch**********@g mail.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
I am using dreamweaver to make an ASP page.
8|
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.

You could use the priority number in your CSS class name like so:
<style type="text/css">
tr.priority1 { background-color: #ff0000; }
tr.priority2 { background-color: #ffff00; }
tr.priorityAndS oOn { background-color: #AndSoOn; }
</style>
<%
Do While Not yourRS.EOF
sPriority = yourRS.Fields.I tem("Priority") .Value & "")
%>
<tr class="priority <%=sPriority%>" >
<td><%=yourRS.F ields.Item("som ething").Value% ></td>
...
</tr>
<%
yourRS.MoveNext
Loop
%>

Ray at work



Jul 27 '05 #4
> Thanks for the quick response. Is there a certain place I need to put
this code???


Uh, well, probably inside the loop...
Jul 27 '05 #5
> tr.priority1 { background-color: #ff0000; }
tr.priority2 { background-color: #ffff00; }


Ooh, I like that approach even better than my suggestion.

I get light-headed when I see HTML code that is half <font color=#blah>
tags... especially when they're all the same. I always find myself pounding
my head against the wall, dying to ask when they're going to look up this
"CSS" concept they may have heard about.
Jul 27 '05 #6
I'm very new to CSS, is this something DWeaver can do in the CSS
Styles??? or do I need to just use the code above??

Chris

Jul 27 '05 #7
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!

Ray at work

"Aaron Bertrand [SQL Server MVP]" <te*****@dnartr eb.noraa> wrote in message
news:uA******** ******@TK2MSFTN GP12.phx.gbl...
tr.priority1 { background-color: #ff0000; }
tr.priority2 { background-color: #ffff00; }
Ooh, I like that approach even better than my suggestion.

I get light-headed when I see HTML code that is half <font color=#blah>
tags... especially when they're all the same. I always find myself

pounding my head against the wall, dying to ask when they're going to look up this
"CSS" concept they may have heard about.

Jul 27 '05 #8
I haven't gotten anything to work so far. I'm probably doing something
wrong. I tried the first code but no color changes. I didn't try the
CSS b/c I don't really know what to do with it. I am very new to this.

Chris

Jul 27 '05 #9
"Chris Stanley" <ch**********@g mail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I haven't gotten anything to work so far. I'm probably doing something
wrong. I tried the first code but no color changes. I didn't try the
CSS b/c I don't really know what to do with it. I am very new to this.


Can you show us the code you have thus far?
Jul 27 '05 #10

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

Similar topics

6
148671
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>
4
3434
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 exception that the page is cleared, and the curser changes (and stays) as an hourglass. In...
5
2705
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. I'd appreciate any ideas how to do this
2
4828
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 the MS Access help index. I can use the OnKeyPress event to trigger a new check for the "best"...
5
18285
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 fields so do not wish to have scores of queries to build my report.
14
2273
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 combobox. Does anybody know the easiest way to do this?
8
18400
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 "CategoryName" is not the primary key for the table -- the PK is
1
4102
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:
16
5191
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
1
4228
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? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
0
9706
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6854
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.