473,585 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

display property of a tr element

I'm trying to dynamically change the visibility of a table row. I can
hide the row, but I'm having trouble making it visible again. This is
what I have:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<script type="text/javascript">
function ready() {
var elem=document.g etElementById( "tr" );
elem.style.disp lay='none';
elem.style.disp lay='table-row';
}
</script></head>
<body onload="ready() ">
<table>
<tr id="tr">
<td>Hello, world!</td>
</tr></table></body></html>

Setting display to "none" works fine, but trying to set it back to
"table-row" (which is what it defaults to, right?) doesn't work (IE
and Firefox both say "invalid argument"). Does the following quote
from the W3C specification mean I can't do this?

"User agents may ignore these 'display' property values for HTML
documents, since authors should not alter an element's expected
behavior." [WRT table-related display property values]

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Jul 21 '05 #1
8 16064
Christopher Benson-Manica wrote:
I'm trying to dynamically change the visibility of a table row. I can
hide the row, but I'm having trouble making it visible again. This is
what I have:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<script type="text/javascript">
function ready() {
var elem=document.g etElementById( "tr" );
elem.style.disp lay='none';
elem.style.disp lay='table-row';


table-row is css2.1. not many browsers support css2.1
you will have more luck using css1
Jul 21 '05 #2
On Mon, 7 Feb 2005 15:17:31 +0000 (UTC) Christopher Benson-Manica wrote:
I'm trying to dynamically change the visibility of a table row. I can
hide the row, but I'm having trouble making it visible again. This is
what I have: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<script type="text/javascript">
function ready() {
var elem=document.g etElementById( "tr" );
elem.style.disp lay='none';
elem.style.disp lay='table-row';
}


elem.style.disp lay="display:bl ock;"
there is no attribute "table-row" which is the reason for the errors.

But why do you want to turn it off then immediately turn it back on?
You should check to see which condition it is in, then reverse as needed.
Jul 21 '05 #3
Christopher Benson-Manica wrote:

[snip]
Setting display to "none" works fine, but trying to set it back to
"table-row" (which is what it defaults to, right?)
In compliant user agents, yes. However IE isn't compliant. It expects
the string 'block' (though that has a different meaning with compliant
user agents). The safest way of restoring the default is to assign an
empty string. Note that this will only work if:

- The document style sheet doesn't hide the element itself (and it
shouldn't for reasons of usability).
- You only modify the *inline* display property via style object.

There is a way to determine the expected value, but that shouldn't be
necessary in most cases.
Firefox [says] "invalid argument"
Which version of Firefox? Recent versions don't.
Does the following quote [snipped] from the W3C specification mean I can't do this?


It suggests you don't, but it doesn't say you can't. It allows vendors
to simplify their implementations . After all, it would be rather
unfair to require a resource-stricken platform to provide that
functionality.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 21 '05 #4
Richard wrote:

[snip]
elem.style.disp lay="display:bl ock;"
Wrong. If you were setting a value of 'block', then assign the string,
'block'.
there is no attribute "table-row" which is the reason for the errors.
Wrong again. Have you read the CSS 2.x Specification?
But why do you want to turn it off then immediately turn it back on? [...]


I believe it's called an experiment. I thought you had a lot of
experience with those?

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 21 '05 #5
Michael Winter <m.******@bluey onder.co.invali d> spoke thus:
In compliant user agents, yes. However IE isn't compliant. It expects
the string 'block' (though that has a different meaning with compliant
user agents). The safest way of restoring the default is to assign an
empty string.
What do you think of changing the class of the element as a possible
alternative?
Which version of Firefox? Recent versions don't.
Hm, it seems that I was suffering from caffeine deficiency earlier
this morning, as I just tested the same page and Firefox was perfectly
happy with it.
It suggests you don't, but it doesn't say you can't. It allows vendors
to simplify their implementations . After all, it would be rather
unfair to require a resource-stricken platform to provide that
functionality.


So IOW changing it is not guaranteed to have an effect, but it is
safe to attempt to do so?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Jul 21 '05 #6
Christopher Benson-Manica wrote:
Michael Winter <m.******@bluey onder.co.invali d> spoke thus:
The safest way of restoring the default is to assign an empty
string.
What do you think of changing the class of the element as a
possible alternative?


I wouldn't say it was very different. However, changing classes should
be a more expensive operation. If you meet the criteria I listed in my
previous post, I'd just go with the empty string.

[snip]
So IOW changing it is not guaranteed to have an effect,
Well, a definitive answer would be that a change to *any* property
isn't guaranteed to have an effect. However, it usually does.
but it is safe to attempt to do so?


Yes. A particularly vicious implementation might raise an exception if
you assign a value that it doesn't understand (but is otherwise valid)
rather than just ignoring it. Apart from that you should be fine.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 21 '05 #7
*Christopher Benson-Manica* <at***@nospam.c yberspace.org>:

I'm trying to dynamically change the visibility of a table row.
Actually you're supposed to use just that property: 'visibility'. The
values would be 'collapse' and 'visible'. Implementation is probably even
worse than for "display: table-row", though.
function ready() {
var elem=document.g etElementById( "tr" );
elem.style.disp lay='none';
elem.style.disp lay='table-row';
}


I would use switched classes and a 'get*' method accepting CSS selectors.

--
Every rose has its þ.
Jul 21 '05 #8
Richard wrote:
Christopher Benson-Manica wrote:

I'm trying to dynamically change the visibility of a table row.
<script type="text/javascript">
function ready() {
var elem=document.g etElementById( "tr" );
elem.style.disp lay='none';
elem.style.disp lay='table-row';
}


elem.style.disp lay="display:bl ock;"


That will set the display to block, not table-row, giving very different
results in Firefox, Opera, and likely other conforming browsers.
there is no attribute "table-row"


You're in over your head. Please stop giving advice until you get a
better grip on the subject.

--
Brian
Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
13861
by: endus | last post by:
I'm having some trouble getting something to work. I'm not even sure whether or not this is possible, but it *seems* like it should be. I've done a fair amount of experimenting and googling...but maybe I'm still missing something obvious... I'm trying to have a <div> appear and disappear based on what a switchbox is set to. Having <div...
3
2601
by: John Smith | last post by:
Hi, I'm trying to write a piece of ASP that will allow me to display only one element of a XML file. I am new to XML and wanted to find out what I am doing wrong. I think it may be to do with the nodes ? When this is currently run it comes up with the error "Overflow" ('800a0006'). Any pointers or solutions ? Thanks
2
1785
by: sandeep02 | last post by:
Any help on the follwing would be great. If i have a business object like the folliwng Object Name : Customer PropertyName Value --------------------------- FirstName John LastName Smith
13
1961
by: Benjamin Smith | last post by:
I am controlling the display status of a table row using the following code. <TR id="CCRow" style="DISPLAY:none"> Instead of hard coding "none" above, I would like to change that value using a hidden input control. How to do that? I am getting the error in the following case. <TR id="CCRow" style="DISPLAY:"
0
868
by: phil2phil | last post by:
Hi, Does anyone know what is the contorl's display property used for? I've seen both: Display="Static" Display="Dynamic" not sure what they apply to, when to use which. Thank you.
6
1484
by: wassa | last post by:
I get different results for div.classname { display:; } and div.classname { display:block; } Bug?
2
8472
by: rn5a | last post by:
The different Validation controls like RequiredFieldValidator, RangeValidator etc. have a property named Display. This property can have 3 values - Dynamic, Static & None. What's the difference between the Dynamic Display & Static Display? Also suppose a Form has 2 TextBoxes & both the TextBoxes have the RequiredFieldValidator. The Form has...
5
2347
by: libsfan01 | last post by:
Hi all Im trying to write a script that pulls data from another page (which is getting data from a db). The contents displayed on the db handling page (display.php) gets transferred through XMLHttpRequest continuously, however when setting the value using getElementById the value of the element is not being replaced, it is being appended...
0
1170
by: =?Utf-8?B?Tmltcm9kIFJvdG5lcg==?= | last post by:
Hi all, I am using two validators contols that perform validation on the same field. I located them side by side and set the first (the left one) Display property to static and the second (the right one) to Dynamic. When the first validator pass (validation OK) and the second validator fail , I still see the spaces and the location of the...
0
8195
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7947
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6596
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5707
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3831
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3856
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2340
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1171
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.