...

View Full Version : Hiding Numerical Values



rockdoc
05-24-2005, 04:02 PM
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...

Kor
05-24-2005, 04:36 PM
Try



<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>

rockdoc
05-24-2005, 05:24 PM
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 )



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum