Hide table/row

J

John M

I want to hide the first row in my table and if a user click on a show
button than show it. If it is visible than user can hide it with click a
hide button.
In default I hide it with:

<tr id="ds" style="display:none">

but how can I make it visible or hide it dynamicaly?

Is it possible to do it not with TR but with TABLE?

Thanks!
 
H

Hywel Jenkins

I want to hide the first row in my table and if a user click on a show
button than show it. If it is visible than user can hide it with click a
hide button.
In default I hide it with:

<tr id="ds" style="display:none">

but how can I make it visible or hide it dynamicaly?

Is it possible to do it not with TR but with TABLE?

<script type="text/javascript">
var tableRow = document.getElementById('ds');
tableRow.style.display = 'none';
// tableRow.style.display = 'block';
</script>
 
D

David Dorward

Hywel said:
<script type="text/javascript">
var tableRow = document.getElementById('ds');
tableRow.style.display = 'none';
// tableRow.style.display = 'block';
</script>

display: block? For a <tr>? Shouldn't that be display: table-row?

(The results of display: block on table cells are ... interesting in Mozilla
(and Opera IIRC). I expect block rows would be almost as undesired)
 
T

Toby A Inkster

David said:
display: block? For a <tr>? Shouldn't that be display: table-row?

I'm not sure how well Internet Explorer would handle that.

Possibly best something like:

<script type="text/javascript">
function hiderow(x) {
if ( document.all ) {
document.getElementById(x).style.visibility="hidden";
} else {
document.getElementById(x).style.display="none";
}
}
function showrow(x) {
if ( document.all ) {
document.getElementById(x).style.visibility="visible";
} else {
document.getElementById(x).style.display="table-row";
}
}
function showcontrols() {
document.getElementById('controls').style.display="block";
}
</script>
<body onload="hiderow('ds');showcontrols();">
<table>
<tr id="ds"><td>Hello World</td></tr>
</table>
<ul style="display:none;" id="controls">
<li onclick="hiderow('ds');">Hide</li>
<li onclick="showrow('ds');">Show</li>
</ul>
</body>

Of course, this will add confusing controls to non-CSS, non-JS browsers.
 
Joined
Jul 1, 2012
Messages
1
Reaction score
0
Please i need help concerning this code. I want to hide rows whose total is zero. Once a row have zero as value for total i want it hidden. I need this assistance asap. Thank you




$query = "SELECT * FROM firsttermsar
WHERE studentID=$stuID AND year=\"$_SESSION[year]\"";
clear.gif
#27
$result = mysql_query($query)
or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<h2> FIRST TERM RESULT for $namet during the SESSION $year</h2>";
echo "<table class='table1'>";

echo "<tr>";
echo "<td><b>Mark Obtainable</b></td>";
echo "<td><b>CA(30)</b>
clear.gif
</td>
<td><b>Exam</b></
clear.gif
td> <td><b>Total(70)</b><
clear.gif
/td><td><b>Grade</b>
clear.gif
</td><td><b>Comment<
clear.gif
/b></td><td><b>Teac
clear.gif
her's Signature</b></td></tr>
clear.gif
";
if ($total>="1")
echo "<td>English Language: </td>";
echo "<td>{$row['firstengtest']}<
clear.gif
/td> <td>{$row['firstengexam']}</td>
clear.gif
<td>";
$total = $row['firstengtest']+$row['firstengexam'
clear.gif
];
echo $total."</td><td>";
clear.gif


if ($total>="70")
echo "A ";
elseif ($total>="60")
echo "B";
elseif ($total>="50")
echo "C";
elseif ($total>="40")
echo "D";
elseif ($total>="30")
echo "E";
elseif ($total=="0")
echo "-";
else
echo "F";


echo "</td><td> </td> <td>";
if ($total>="70")
echo "EXCELLENT";
elseif ($total>="60")
echo "VERY GOOD";
elseif ($total>="50")
echo "GOOD";
elseif ($total>="40")
echo "PASS";
elseif ($total>="30")
echo "POOR";
elseif ($total=="0")
echo "-";
else
echo "FAIL";
echo "</td></tr>";

echo "<tr>";
echo "<td>Mathematics </td>";
echo "<td>{$row['firstmathtest']}<
clear.gif
/td> <td>{$row['firstmathexam']}</td
clear.gif
> <td>";
$total = $row['firstmathtest']+$row['firstmathexa
clear.gif
m'];
echo $total."</td><td>";
clear.gif


if ($total>="70")
echo "A";
elseif ($total>="60")
echo "B";
elseif ($total>="50")
echo "C";
elseif ($total>="40")
echo "D";
elseif ($total>="30")
echo "E";
elseif ($total=="0")
echo "-";
else
echo "F";



echo "</td><td> </td> <td>";
if ($total>="70")
echo "EXCELLENT";
elseif ($total>="60")
echo "VERY GOOD";
elseif ($total>="50")
echo "GOOD";
elseif ($total>="40")
echo "PASS";
elseif ($total>="30")
echo "POOR";
elseif ($total=="0")
echo "-";
else
echo "FAIL";
echo "</td></tr>";

echo "<tr>";
echo "<td>Physics: </td>";
echo "<td>{$row['firstphytest']}<
clear.gif
/td> <td>{$row['firstphyexam']}</td>
clear.gif
<td>";
$total = $row['firstphytest']+$row['firstphyexam'
clear.gif
];
echo $total."</td><td>";
clear.gif


if ($total>="70")
echo "A";
elseif ($total>="60")
echo "B";
elseif ($total>="50")
echo "C";
elseif ($total>="40")
echo "D";
elseif ($total>="30")
echo "E";
elseif ($total=="0")
echo "-";
else
echo "F";


echo "</td><td> </td> <td>";
if ($total>="70")
echo "EXCELLENT";
elseif ($total>="60")
echo "VERY GOOD";
elseif ($total>="50")
echo "GOOD";
elseif ($total>="40")
echo "PASS";
elseif ($total>="30")
echo "POOR";
elseif ($total=="0")
echo "-";
else
echo "FAIL";
echo "</td></tr>";

echo "<tr>";
echo "<td>Chemistry: </td>";
echo "<td>{$row['firstchemtest']}<
clear.gif
/td> <td>{$row['firstchemexam']}</td
clear.gif
> <td>";
$total = $row['firstchemtest']+$row['firstchemexa
clear.gif
m'];
echo $total."</td><td>";
clear.gif


if ($total>="70")
echo "A";
elseif ($total>="60")
echo "B";
elseif ($total>="50")
echo "C";
elseif ($total>="40")
echo "D";
elseif ($total>="30")
echo "E";
elseif ($total=="0")
echo "-";
else
echo "F";



echo "</td><td> </td> <td></td></tr>";
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top