row value

A

atse

Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
....
....

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7 "IL".

What I want is that the same values display a special color, such as RED,
<font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I get the
values of "field[state]"?
Thanks for any idea?

Atse
 
A

Adrienne

Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
...
...

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7 "IL".

What I want is that the same values display a special color, such as RED,
<font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I get the
values of "field[state]"?
Thanks for any idea?

Atse

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Using Colors</title>
<style type="text/css">
..red {color:red; background-color: transparent}
..green {color:green; background-color: transparent}
</style>
</head>
<body>
<table summary="Color samples">
<thead>
<tr>
<th>id</th><th>name</th><th>state</th><th>zip</th>
</thead>
<tbody>
<% while not rsrecordset.EOF
id = rsrecordset("id")
name = rsrecordset("name")
state = rsrecordset("state")
zip = rsrecordset("zip")

select case state
case "NJ"
class = "red"
case "IL"
class = "red"
case else
class = "green"
end select
%>
<tr>
<td><%=id%></td><td><%=name%><td><span class="<%=class%>"><%=state%></span>
</td><td><%=zip%></td>
</tr>
<% rsrecordset.movenext
wend
rsrecordset.Close
set rsrecordset = nothing
%>
</tbody>
</table>
</body>
</html>
 
T

Tim Williams

you want to display *any* repeating value in red, or just the specific
values NJ and IL?

are you ordering by state? would have to for this to work

any way, assuming you want to color *any* repeating value and the rs is
ordered by state:


'just using two of your fields to save typing...

dim ostate, nstate,sclass ' if "name" is really your field name then
change it

if not rs.eof then

ostate=rs("state").value

sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" & rs("name").value
& "</td></tr>"
sclass="notred"
rs.movenext

if not rs.eof then
do while not rs.eof

nstate=rs("state")

sclass="notred"
if nstate=ostate then sclass="red"

response.write replace(sRow,"~xxx~",sclass)

ostate=nstate
sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"

rs.movenext
loop
end if

response.write replace(sRow,"~xxx~",sclass)

end if

untested, but you get the idea. might fail if there's only one row, but you
get the idea

tim
 
A

atse

Yes, your assumption is right. I need to make the repeating values red in
the sorted "state" column. I will try your solution. If not work, I will ask
again. Thanks a lot.

Tim Williams said:
you want to display *any* repeating value in red, or just the specific
values NJ and IL?

are you ordering by state? would have to for this to work

any way, assuming you want to color *any* repeating value and the rs is
ordered by state:


'just using two of your fields to save typing...

dim ostate, nstate,sclass ' if "name" is really your field name then
change it

if not rs.eof then

ostate=rs("state").value

sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" & rs("name").value
& "</td></tr>"
sclass="notred"
rs.movenext

if not rs.eof then
do while not rs.eof

nstate=rs("state")

sclass="notred"
if nstate=ostate then sclass="red"

response.write replace(sRow,"~xxx~",sclass)

ostate=nstate
sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"

rs.movenext
loop
end if

response.write replace(sRow,"~xxx~",sclass)

end if

untested, but you get the idea. might fail if there's only one row, but you
get the idea

tim




atse said:
Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
...
...

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7 "IL".

What I want is that the same values display a special color, such as RED,
<font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I get the
values of "field[state]"?
Thanks for any idea?

Atse
 
D

dlbjr

do while not rs.eof
intID = rs("id")
strName = rs("name")
strState = rs("state")
strZIP = rs("zip")
With Response
.Write "<tr><td class='"
.Write GetStyle(strState)
.Write "'>"
.Write strState
.Write "</td><td>"
.Write strName
.Write "</td></tr>"
End With
rs.movenext
loop

Function GetStyle(strItem)
Select Case UCase(Trim(strItem))
Case "NJ","IL"
GetStyle = "red"
Case Else
GetStyle = ""
End Select
End Function

-dlbjr

Discerning resolutions for the alms
 
A

atse

Further question please.

I usually get the row number like below:

dim nb
nb = 0

if not rs.eof then
do until rs.eof
nb = nb + 1
Response.Write "<tr><td>" & nb & "</td><td>" & rs(0) &
"</td>.........</tr>"
rs.movenext
loop
end if

' Then I get the row number. How can I do in your solution so that I can get
that number? Thanks

Tim Williams said:
you want to display *any* repeating value in red, or just the specific
values NJ and IL?

are you ordering by state? would have to for this to work

any way, assuming you want to color *any* repeating value and the rs is
ordered by state:


'just using two of your fields to save typing...

dim ostate, nstate,sclass ' if "name" is really your field name then
change it

if not rs.eof then

ostate=rs("state").value

sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" & rs("name").value
& "</td></tr>"
sclass="notred"
rs.movenext

if not rs.eof then
do while not rs.eof

nstate=rs("state")

sclass="notred"
if nstate=ostate then sclass="red"

response.write replace(sRow,"~xxx~",sclass)

ostate=nstate
sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"

rs.movenext
loop
end if

response.write replace(sRow,"~xxx~",sclass)

end if

untested, but you get the idea. might fail if there's only one row, but you
get the idea

tim




atse said:
Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
...
...

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7 "IL".

What I want is that the same values display a special color, such as RED,
<font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I get the
values of "field[state]"?
Thanks for any idea?

Atse
 
B

Bob Barrows

Why not use rs.AbsolutePosition?
Bob Barrows
atse said:
Further question please.

I usually get the row number like below:

dim nb
nb = 0

if not rs.eof then
do until rs.eof
nb = nb + 1
Response.Write "<tr><td>" & nb & "</td><td>" & rs(0) &
"</td>.........</tr>"
rs.movenext
loop
end if

' Then I get the row number. How can I do in your solution so that I
can get that number? Thanks

Tim Williams said:
you want to display *any* repeating value in red, or just the
specific values NJ and IL?

are you ordering by state? would have to for this to work

any way, assuming you want to color *any* repeating value and the rs
is ordered by state:


'just using two of your fields to save typing...

dim ostate, nstate,sclass ' if "name" is really your field name
then change it

if not rs.eof then

ostate=rs("state").value

sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"
sclass="notred"
rs.movenext

if not rs.eof then
do while not rs.eof

nstate=rs("state")

sclass="notred"
if nstate=ostate then sclass="red"

response.write replace(sRow,"~xxx~",sclass)

ostate=nstate
sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"

rs.movenext
loop
end if

response.write replace(sRow,"~xxx~",sclass)

end if

untested, but you get the idea. might fail if there's only one row,
but you get the idea

tim




atse said:
Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
...
...

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7 "IL".

What I want is that the same values display a special color, such
as RED, <font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I
get the values of "field[state]"?
Thanks for any idea?

Atse
 
A

atse

Can you tell me more about that? Thanks.


Bob Barrows said:
Why not use rs.AbsolutePosition?
Bob Barrows
atse said:
Further question please.

I usually get the row number like below:

dim nb
nb = 0

if not rs.eof then
do until rs.eof
nb = nb + 1
Response.Write "<tr><td>" & nb & "</td><td>" & rs(0) &
"</td>.........</tr>"
rs.movenext
loop
end if

' Then I get the row number. How can I do in your solution so that I
can get that number? Thanks

Tim Williams said:
you want to display *any* repeating value in red, or just the
specific values NJ and IL?

are you ordering by state? would have to for this to work

any way, assuming you want to color *any* repeating value and the rs
is ordered by state:


'just using two of your fields to save typing...

dim ostate, nstate,sclass ' if "name" is really your field name
then change it

if not rs.eof then

ostate=rs("state").value

sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"
sclass="notred"
rs.movenext

if not rs.eof then
do while not rs.eof

nstate=rs("state")

sclass="notred"
if nstate=ostate then sclass="red"

response.write replace(sRow,"~xxx~",sclass)

ostate=nstate
sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"

rs.movenext
loop
end if

response.write replace(sRow,"~xxx~",sclass)

end if

untested, but you get the idea. might fail if there's only one row,
but you get the idea

tim




Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
...
...

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7 "IL".

What I want is that the same values display a special color, such
as RED, <font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I
get the values of "field[state]"?
Thanks for any idea?

Atse
 
B

Bob Barrows

http://msdn.microsoft.com/library/en-us/ado270/htm/mdapro01_2.asp
Can you tell me more about that? Thanks.


Bob Barrows said:
Why not use rs.AbsolutePosition?
Bob Barrows
atse said:
Further question please.

I usually get the row number like below:

dim nb
nb = 0

if not rs.eof then
do until rs.eof
nb = nb + 1
Response.Write "<tr><td>" & nb & "</td><td>" & rs(0) &
"</td>.........</tr>"
rs.movenext
loop
end if

' Then I get the row number. How can I do in your solution so that I
can get that number? Thanks

you want to display *any* repeating value in red, or just the
specific values NJ and IL?

are you ordering by state? would have to for this to work

any way, assuming you want to color *any* repeating value and the
rs is ordered by state:


'just using two of your fields to save typing...

dim ostate, nstate,sclass ' if "name" is really your field name
then change it

if not rs.eof then

ostate=rs("state").value

sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"
sclass="notred"
rs.movenext

if not rs.eof then
do while not rs.eof

nstate=rs("state")

sclass="notred"
if nstate=ostate then sclass="red"

response.write replace(sRow,"~xxx~",sclass)

ostate=nstate
sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
rs("name").value & "</td></tr>"

rs.movenext
loop
end if

response.write replace(sRow,"~xxx~",sclass)

end if

untested, but you get the idea. might fail if there's only one
row, but you get the idea

tim




Hi,

I select * from a table in the database, for example

id name state zip
1 Smith OH 12345
2 John NJ 22541
3 Jack NJ 22536
4 Andy NJ 66541
5 Jay CA 22444
6 Peter IL 23522
7 Ray IL 23514
...
...

Please focus on "state", row 2, 3 and 4 are "NJ"; row 6 and 7
"IL".

What I want is that the same values display a special color, such
as RED, <font color=red>field[state]</font>.
In this case, NJ and IL in the table will display RED. How can I
get the values of "field[state]"?
Thanks for any idea?

Atse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,126
Messages
2,570,750
Members
47,308
Latest member
TorriLangr

Latest Threads

Top