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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding Numerical Values

    Hello,
    I have a perl script that pulls numerical values from a text file and puts them into an html template. E.g.

    <table>
    <tr><td> [[value1]] </td><td> [[value2]] </td> <td> [[value3]] </td></tr>
    etc
    etc
    </table>

    What I want to do is hide all the values that are equal to zero.

    I thought this could be achieved by making these values the same color as the table background?

    Any help to get me started would be much appreciated...

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try

    Code:
    <script type="text/javascript">
    onload=function(){
    var allC = document.getElementsByTagName('td');
    for(var i=0;i<allC.length;i++){
    if(allC[i].firstChild.data=='0'){
    allC[i].firstChild.data=' ';
    }
    }
    </script>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks...I'll work on that (initial attempt failed)


    Later...
    Eventually did it using css to change the zero values to the background color of the table.

    <style>
    .sheet0 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: bold;
    color: #ffffc4;} //background color of the table to hide "0" values

    .sheet1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: bold;
    color: #ff0033;} //other values will stand out as red

    etc
    </style>

    If [[value]] is zero it will be "hidden from view"

    <table>
    <tr>
    <td>
    <span class="sheet[[value1]]"> [[value]] </span> </td>
    <td><span class="sheet[[value1]]"> [[value]] </span></td>
    <td> <span class="sheet[[value1]]"> [[value]] </span></td></tr>
    etc
    etc
    </table>

    As my number range is only 0-12 I only had to define 12 styles (actually only 2 styles... zero and 1-12 )
    Last edited by rockdoc; 05-25-2005 at 03:59 PM.


  •  

    Posting Permissions

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