473,503 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide table/row

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


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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2256
by: Michael Skind | last post by:
Hello, I use a simple Table : <TABLE> <TR 1> <TD></TD> </TR> <TR 2> <TD></TD> </TR>
7
4117
by: Mad Scientist Jr | last post by:
Through messing around I got IE6 (win xp) to show/hide a table row. I gave my <TR> an ID of "trRow" and trRow.style.display='none'; hides it trRow.style.display='block'; displays it (will any...
1
11891
by: Don Grover | last post by:
I have a table thats wrapped in a div tag, that when user selects 1 of 2 radio buttons it hides or shows table, this works ok. But I want to set the table show hide on what the existing state of...
9
33391
by: Wang, Jay | last post by:
I try to group several rows in a table into a div and show/hide them by click on a button somewhere with a javascript link. When clicked, the link will toggle the style of the div section's style...
19
6854
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
10
4625
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
11
7999
by: jimstruckster | last post by:
I have a table with 10 rows, I want all rows except for the first to be hidden when the page first opens up. If the user puts a value in a text box in the first row then I want the second row to...
10
2959
by: Phillip Vong | last post by:
Newbie here on ASP.NET I want to hide a Table with and OnClick event. How do you do that? I'm not showing an ID when I create a table so how do I tell it to hide it? Is there a way to add an...
1
4150
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.