By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,930 Members | 633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,930 IT Pros & Developers. It's quick & easy.

Hide table/row

P: n/a
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!

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


John M wrote:
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?


function hideElement (elementId) {
var element;
if (document.all)
element = document.all[elementId];
else if (document.getElementById)
element = document.getElementById(elementId);
if (element && element.style)
element.style.display = 'none';
}
function showElement (elementId) {
var element;
if (document.all)
element = document.all[elementId];
else if (document.getElementById)
element = document.getElementById(elementId);
if (element && element.style)
element.style.display = '';
}

Now you can call
showElement('ds');
to show the table row.
However as not all browsers support JavaScript and even some of those
that do don't support toggling style.display it is better if you don't use
<tr id="ds" style="display:none">
to hide the row but rather do it with script e.g.
<table>
<tr id="ds">
<td>...</td>
...
</tr>
...
</table>
<script type="text/javascript">
hideElement('ds');
</script>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a

Can you use style.display with labels too or not as I am trying it and
I keep getting label is null but if I use an input textbox then it works

Thanks

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:3f********@olaf.komtel.net...


John M wrote:
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?


function hideElement (elementId) {
var element;
if (document.all)
element = document.all[elementId];
else if (document.getElementById)
element = document.getElementById(elementId);
if (element && element.style)
element.style.display = 'none';
}
function showElement (elementId) {
var element;
if (document.all)
element = document.all[elementId];
else if (document.getElementById)
element = document.getElementById(elementId);
if (element && element.style)
element.style.display = '';
}

Now you can call
showElement('ds');
to show the table row.
However as not all browsers support JavaScript and even some of those
that do don't support toggling style.display it is better if you don't use
<tr id="ds" style="display:none">
to hide the row but rather do it with script e.g.
<table>
<tr id="ds">
<td>...</td>
...
</tr>
...
</table>
<script type="text/javascript">
hideElement('ds');
</script>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.