Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How change color of text based on the value

    I am preparing a table which shows result of 5 students with grade AB,BB,FF
    I want to change color of text FF to red and other grades to color GREEN.
    How to do this in XHTML. I had also tired to use CSS, but in CSS also I dont know how to change of text depending on its value.


    Thanks a lot in advance.

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Source code? Examples of what you've tried? This sounds like a homework problem, and for those we can only offer suggestions.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Alex Vincent View Post
    Source code? Examples of what you've tried? This sounds like a homework problem, and for those we can only offer suggestions.
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">
    <head>
    
    <style type="text/css">
    
    td{
      <FONT COLOR="#FF0000">FF</FONT>
       <FONT COLOR="green">AB</FONT>
    }
    
    </style>
    
    </head>
    <wml>
      <card id="page1" title="Table in WML">
        <p>
          <table columns="3">
            <tr>
              <td>Student Name &nbsp &nbsp &nbsp&nbsp</td>
              <td>Subject Name &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</td>
                 <td>Marks</td>
             
             
            </tr>
    
            <tr>
              <td>SHYJU</td>
              <td>Information Security</td>
                <td>BB</td>      
            </tr>
    <tr>
              <td></td>
              <td>DCA</td>
                <td>BC</td>      
            </tr>
    
    <tr>
    <tr>
              <td></td>
              <td>WNMC</td>
                <td>AB</td>      
            </tr>
    
    <tr>
              <td>Sanal</td>
              <td>Information Security</td>
                <td>BB</td>  
    
        
            </tr>
    <tr>
              <td></td>
              <td>DCA</td>
                <td>BC</td>      
            </tr>
    
    <tr>
    <tr>
              <td></td>
              <td>WNMC</td>
                <td>AB</td>      
            </tr>
    
    <tr>
              <td>Darshan</td>
              <td>Information Security</td>
                <td>AB</td>      
            </tr>
    
    <tr>
    <tr>
              <td></td>
              <td>DCA</td>
                <td>FF</td>      
            </tr>
    
    <tr>
    <tr>
              <td></td>
              <td>WNMC</td>
                <td>AB</td>      
            </tr>
              <td>Aakash</td>
              <td>Information Security</td>
                <td> 
    <font color="green">AB</font>
       </td>
            </tr>
    
    <tr>
              <td></td>
              <td>DCA</td>
                <td>FF</td>      
            </tr>
    
    <tr>
    <tr>
              <td></td>
              <td>WNMC</td>
                <td>AB</td>      
            </tr>
    <tr>
              <td>Betu</td>
              <td>Information Security</td>
                <td>   
                <FONT COLOR="red">FF</FONT>  
      
     </td>
            </tr>
    <tr>
              <td></td>
              <td>DCA</td>
                <td>FF</td>      
            </tr>
    
    <tr>
    <tr>
              <td></td>
              <td>WNMC</td>
                <td>AB</td>      
            </tr>
          </table>
        </p>
      </card>
    </wml>
    Last edited by VIPStephan; 04-30-2014 at 06:31 PM. Reason: added code BB tags

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,081
    Thanks
    23
    Thanked 592 Times in 591 Posts
    A little confused here. This is the XML forum and you have <?xml version="1.0"?> as the first line in your code, but your code is not XML.
    You ask "How to do this in XHTML?" So that is what I attempted.
    FYI: <FONT COLOR="#FF0000">FF</FONT> is code no longer used. In style CSS section we just change the color of the text, as shown below.
    <table columns="3">; columns is not an attribute. Not sure what <wml><card id="page1" title="Table in WML"> is for??
    This is a HTML page
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <title>Title of document</title><!--  MUST HAVE IN AN XHTML DOCUMENT  -->
    <style type="text/css">
    .pass{
    color: green;
    }
    .fail{
    color: red;
    }
    </style>
    </head>
    
    <body>
    <table>
    <tr>
    <td>Student Name &nbsp &nbsp &nbsp&nbsp</td>
    <td>Subject Name &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</td>
    <td>Marks</td>
    
    
    </tr>
    
    <tr>
    <td>SHYJU</td>
    <td>Information Security</td>
    <td class="pass">BB</td>
    </tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="pass">BC</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    
    <tr>
    <td>Sanal</td>
    <td>Information Security</td>
    <td class="pass">BB</td>
    
    
    </tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="pass">BC</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    
    <tr>
    <td>Darshan</td>
    <td>Information Security</td>
    <td class="pass">AB</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="fail">FF</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    <td>Aakash</td>
    <td>Information Security</td>
    <td>
    </td>
    </tr>
    
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="fail">FF</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    <tr>
    <td>Betu</td>
    <td>Information Security</td>
    <td>
    
    </td>
    </tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="fail">FF</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <<td class="pass">AB</td>
    </tr>
    </table>
    </body>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #5
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    A little confused here. This is the XML forum and you have <?xml version="1.0"?> as the first line in your code, but your code is not XML.
    You ask "How to do this in XHTML?" So that is what I attempted.
    FYI: <FONT COLOR="#FF0000">FF</FONT> is code no longer used. In style CSS section we just change the color of the text, as shown below.
    <table columns="3">; columns is not an attribute. Not sure what <wml><card id="page1" title="Table in WML"> is for??
    This is a HTML page
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <title>Title of document</title><!--  MUST HAVE IN AN XHTML DOCUMENT  -->
    <style type="text/css">
    .pass{
    color: green;
    }
    .fail{
    color: red;
    }
    </style>
    </head>
    
    <body>
    <table>
    <tr>
    <td>Student Name * * **</td>
    <td>Subject Name * * * * * * * *</td>
    <td>Marks</td>
    
    
    </tr>
    
    <tr>
    <td>SHYJU</td>
    <td>Information Security</td>
    <td class="pass">BB</td>
    </tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="pass">BC</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    
    <tr>
    <td>Sanal</td>
    <td>Information Security</td>
    <td class="pass">BB</td>
    
    
    </tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="pass">BC</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    
    <tr>
    <td>Darshan</td>
    <td>Information Security</td>
    <td class="pass">AB</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="fail">FF</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    <td>Aakash</td>
    <td>Information Security</td>
    <td>
    </td>
    </tr>
    
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="fail">FF</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <td class="pass">AB</td>
    </tr>
    <tr>
    <td>Betu</td>
    <td>Information Security</td>
    <td>
    
    </td>
    </tr>
    <tr>
    <td></td>
    <td>DCA</td>
    <td class="fail">FF</td>
    </tr>
    
    <tr>
    <tr>
    <td></td>
    <td>WNMC</td>
    <<td class="pass">AB</td>
    </tr>
    </table>
    </body>
    Yes I had tried to used in HTML first, so you tell how to do this in HTML . Thanks

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,623
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Quote Originally Posted by sunfighter View Post
    Not sure what <wml><card id="page1" title="Table in WML"> is for??
    WML is the Wireless Markup Language.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •