row value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • atse

    row value

    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


  • Adrienne

    #2
    Re: row value

    Gazing into my crystal ball I observed "atse" <dunggaze@yahoo .com> writing
    in news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com:
    [color=blue]
    > 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
    >
    >
    >[/color]

    <?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("na me")
    state = rsrecordset("st ate")
    zip = rsrecordset("zi p")

    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.mov enext
    wend
    rsrecordset.Clo se
    set rsrecordset = nothing
    %>
    </tbody>
    </table>
    </body>
    </html>


    --
    Adrienne Boswell
    Please respond to the group so others can share

    Comment

    • Tim Williams

      #3
      Re: row value

      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("stat e").value

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

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

      nstate=rs("stat e")

      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").valu e & "</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" <dunggaze@yahoo .com> wrote in message
      news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com...[color=blue]
      > 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
      >
      >[/color]


      Comment

      • atse

        #4
        Re: row value

        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" <saxifrax@pacbe ll*dot*net> wrote in message
        news:OAfOu%236j DHA.1004@tk2msf tngp13.phx.gbl. ..[color=blue]
        > 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("stat e").value
        >
        > sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &[/color]
        rs("name").valu e[color=blue]
        > & "</td></tr>"
        > sclass="notred"
        > rs.movenext
        >
        > if not rs.eof then
        > do while not rs.eof
        >
        > nstate=rs("stat e")
        >
        > 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").valu e & "</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[/color]
        you[color=blue]
        > get the idea
        >
        > tim
        >
        >
        >
        >
        > "atse" <dunggaze@yahoo .com> wrote in message
        > news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com...[color=green]
        > > 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[/color][/color]
        RED,[color=blue][color=green]
        > > <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
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • dlbjr

          #5
          Re: row value

          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(strSta te)
          .Write "'>"
          .Write strState
          .Write "</td><td>"
          .Write strName
          .Write "</td></tr>"
          End With
          rs.movenext
          loop

          Function GetStyle(strIte m)
          Select Case UCase(Trim(strI tem))
          Case "NJ","IL"
          GetStyle = "red"
          Case Else
          GetStyle = ""
          End Select
          End Function

          -dlbjr

          Discerning resolutions for the alms


          Comment

          • atse

            #6
            Re: row value

            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" <saxifrax@pacbe ll*dot*net> wrote in message
            news:OAfOu%236j DHA.1004@tk2msf tngp13.phx.gbl. ..[color=blue]
            > 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("stat e").value
            >
            > sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &[/color]
            rs("name").valu e[color=blue]
            > & "</td></tr>"
            > sclass="notred"
            > rs.movenext
            >
            > if not rs.eof then
            > do while not rs.eof
            >
            > nstate=rs("stat e")
            >
            > 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").valu e & "</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[/color]
            you[color=blue]
            > get the idea
            >
            > tim
            >
            >
            >
            >
            > "atse" <dunggaze@yahoo .com> wrote in message
            > news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com...[color=green]
            > > 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[/color][/color]
            RED,[color=blue][color=green]
            > > <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
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Bob Barrows

              #7
              Re: row value

              Why not use rs.AbsolutePosi tion?
              Bob Barrows
              atse wrote:[color=blue]
              > 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" <saxifrax@pacbe ll*dot*net> wrote in message
              > news:OAfOu%236j DHA.1004@tk2msf tngp13.phx.gbl. ..[color=green]
              >> 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("stat e").value
              >>
              >> sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
              >> rs("name").valu e & "</td></tr>"
              >> sclass="notred"
              >> rs.movenext
              >>
              >> if not rs.eof then
              >> do while not rs.eof
              >>
              >> nstate=rs("stat e")
              >>
              >> 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").valu e & "</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" <dunggaze@yahoo .com> wrote in message
              >> news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com...[color=darkred]
              >>> 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[/color][/color][/color]



              Comment

              • atse

                #8
                Re: row value

                Can you tell me more about that? Thanks.


                "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
                news:eA26T0LkDH A.3504@TK2MSFTN GP11.phx.gbl...[color=blue]
                > Why not use rs.AbsolutePosi tion?
                > Bob Barrows
                > atse wrote:[color=green]
                > > 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" <saxifrax@pacbe ll*dot*net> wrote in message
                > > news:OAfOu%236j DHA.1004@tk2msf tngp13.phx.gbl. ..[color=darkred]
                > >> 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("stat e").value
                > >>
                > >> sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
                > >> rs("name").valu e & "</td></tr>"
                > >> sclass="notred"
                > >> rs.movenext
                > >>
                > >> if not rs.eof then
                > >> do while not rs.eof
                > >>
                > >> nstate=rs("stat e")
                > >>
                > >> 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").valu e & "</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" <dunggaze@yahoo .com> wrote in message
                > >> news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com...
                > >>> 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[/color][/color]
                >
                >
                >[/color]


                Comment

                • Bob Barrows

                  #9
                  Re: row value

                  Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.


                  atse wrote:[color=blue]
                  > Can you tell me more about that? Thanks.
                  >
                  >
                  > "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message
                  > news:eA26T0LkDH A.3504@TK2MSFTN GP11.phx.gbl...[color=green]
                  >> Why not use rs.AbsolutePosi tion?
                  >> Bob Barrows
                  >> atse wrote:[color=darkred]
                  >>> 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" <saxifrax@pacbe ll*dot*net> wrote in message
                  >>> news:OAfOu%236j DHA.1004@tk2msf tngp13.phx.gbl. ..
                  >>>> 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("stat e").value
                  >>>>
                  >>>> sRow="<tr><td class='~xxx~'>" & ostate & "</td><td>" &
                  >>>> rs("name").valu e & "</td></tr>"
                  >>>> sclass="notred"
                  >>>> rs.movenext
                  >>>>
                  >>>> if not rs.eof then
                  >>>> do while not rs.eof
                  >>>>
                  >>>> nstate=rs("stat e")
                  >>>>
                  >>>> 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").valu e & "</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" <dunggaze@yahoo .com> wrote in message
                  >>>> news:NeHhb.7349 9$ko%.54311@new s04.bloor.is.ne t.cable.rogers. com...
                  >>>>> 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[/color][/color][/color]



                  Comment

                  Working...