473,473 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

JavaScript/CSS/DOM issue

Please excuse me If I am posting to the wrong group. I was recommended
here from one of the Database groups I regularly track.

I have a small script that loads a table with some elements visiblity =
hidden and display = none. When clicking on the link it "opens" the
hidden table elements. When click on the link again it "hides" the
elements.

Now this works dandy in IE but in FireFox the element "opens" but when
you click on it again to "hide" the text in the cell disappears but the
actual element itself does not "dissappear" leaving a big blank space.

Working sample is here http://www.jhdesigninc.com/testJava.asp Its not
"pretty" because I eliminated all the code I possible could to make the
problem easier to understand.

Code Sample-----------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<Meta Http-Equiv="Content-Type" Content="text/html;
charset=iso-8859-1">
<titleblah-blah </title>
<style type="text/css">
<!--
..style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
-->
</style>
<script type="text/JavaScript">
function changeView(objChange){
/*have tried sniffing browser and not using getElement
didnt seem to help with display or visibilty
Im missing something really basic
*/
if (document.getElementById(objChange).style.visibili ty ==
'visible'){
document.getElementById(objChange).style.display = "none";
document.getElementById(objChange).style.visibilit y = "hidden";
} else {
document.getElementById(objChange).style.display = "block";
document.getElementById(objChange).style.visibilit y =
"visible";
}

}
</SCRIPT>
</head>
<body>

<table width="449" border="0" cellspacing="1" cellpadding="1">
<tr valign="top">
<td width="100%" align="left" nowrap<span class="style1">Click on
the LINK Its works in IE and Netscape but not Fox. <br>

The window does not go to display:none and visibility:hidden<br>
In Firefox compare IE and Firefox by clicking on the view<br>
button multiple times in both browsers
</span><br>
<br>
<BR>

<table width="100%" border="0" cellspacing="2" cellpadding="0"
id="clickTbl">
<tr class="tblHeader">
<td class="tblHeader">Approver</td>
<td class="tblHeader">Status</td>

<td class="tblHeader">Date</td>
<td class="tblHeader">Time</td>
<td class="tblHeader">Notes</td>
</tr>
<tr>
<td>Bill Gordon</td>
<td>&nbsp;Awaiting Approval</td>

<td>&nbsp;Pending</td>
<td>&nbsp;Pending</td>
<td>&nbsp;<a href="#" onClick="changeView('notes');">View
</a></td>
</tr>
<tr id="notes" style="visibility:hidden; display:none;">
<td colspan="5" bgcolor="#993399"><p>some tesa safd asfd
asddfdasdf
fasd fasfd as dfas df asdf asdf asdf as dfas df asdf asd
f asdf
asdf asd asdfasda</p>
<p>asdasdfasdf</p>

<p>asdf</p>
<p>a</p>
<p>sdf </p></td>
</tr>
<tr>
<td>Brenda Hudson</td>
<td>&nbsp;Under Review</td>

<td>&nbsp;Pending</td>
<td>&nbsp;Pending</td>
<td>&nbsp;Cell Below Not Relevant</td>
</tr>
</table></td>
</tr>
</table>
</body>

</html>
End Code-------------------------------

Any help would be greatly appreciated.

Thanks,
Earl

Sep 9 '06 #1
14 1713


ea*******@gmail.com wrote:

I have a small script that loads a table with some elements visiblity =
hidden and display = none. When clicking on the link it "opens" the
hidden table elements. When click on the link again it "hides" the
elements.

Now this works dandy in IE but in FireFox the element "opens" but when
you click on it again to "hide" the text in the cell disappears but the
actual element itself does not "dissappear" leaving a big blank space.
First of all if you toggle the CSS display property to show/hide
elements then there is no need at all to toggle the CSS visibility
property as well. You can leave visibility alone and simply toggle display.
Then the remaining problem is that CSS 2 defines various possible
display values, for table row elements like the HTML tr elements
'table-row' is the right value and not 'block'. Only IE till version 6
does not support that.
As long as you are using inline styles the solution however is simple:
to hide set e.g.
elementObject.style.display = 'none';
to show it suffices to do
elementObject.style.display = '';
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 9 '06 #2
ea*******@gmail.com wrote:
I have a small script that loads a table with some elements visiblity =
hidden and display = none. When clicking on the link it "opens" the
hidden table elements. When click on the link again it "hides" the
elements.
Hi Earl,

I played with your example and think i found the problem. You are using
display="block" for a table row when it should be display="table-row".

You don't need to toggle both "display" and "visibility. Just toggling
"display" should be fine. If you want to toggle "visibility" you can do
that too but it shouldn't make a difference.

Nested tables are scary and probably not necessary.

The "return false;" I added makes it so the URL doesn't have a '#'
after clicking the link

Adjusted example below.

-Peter
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<Meta Http-Equiv="Content-Type" Content="text/html;
charset=iso-8859-1">
<titleblah-blah </title>

<script type="text/javascript">

function changeView(objChange){
var el = document.getElementById(objChange)
if (el){
if (el.style.display.toLowerCase() !== 'none'){
el.style.display = "none";
} else {
el.style.display = "table-row";
// this works too as long as the display style is not set in
a css file etc
//el.style.display = "";
}
}
}
</script>
</head>
<body>

<p>
Click on the LINK Its works in IE and Netscape but not Fox.
The window does not go to display:none and visibility:hidden
In Firefox compare IE and Firefox by clicking on the view
button multiple times in both browsers
</p>

<table width="100%" border="0" cellspacing="2" cellpadding="0"
id="clickTbl">
<tr>
<td>Bill Gordon</td>
<td>Awaiting Approval</td>
<td>Pending</td>
<td>Pending</td>
<td><a href="#" onClick="changeView('notes');return
false;">View</a></td>
</tr>
<tr id="notes" style="display:none">
<td colspan="5" bgcolor="#993399">
<p>some tesa safd asfd asddfdasdf
fasd fasfd as dfas df asdf asdf asdf as dfas df asdf asdf asdf
asdf asd asdfasda</p>
<p>asdasdfasdf</p>
<p>asdf</p>
<p>a</p>
<p>sdf </p>
</td>
</tr>
<tr>
<td>Brenda Hudson</td>
<td>Under Review</td>
<td>Pending</td>
<td>Pending</td>
<td>Cell Below Not Relevant</td>
</tr>
</table>

</body>
</html>

Sep 9 '06 #3
Thank you peter & martin for your input. If I am missing something you
are telling me bang me over the head with it.

I have tried elementObject.style.display = 'none'; and it did not
rectify the issue
elementObject.style.display = ''; as far as I know that call is
invalid.

If you have it working with Firefox can you just send me a link so I
can see what needs to be done.

Im sorry Table-row has nothing to do with the issue. The issue is the
html element will not collapse again. I know how to adjust the display
I dont know how to Collapse the element again.

Earl

Sep 9 '06 #4

surf_doggie wrote:
Thank you peter & martin for your input. If I am missing something you
are telling me bang me over the head with it.

I have tried elementObject.style.display = 'none'; and it did not
rectify the issue
elementObject.style.display = ''; as far as I know that call is
invalid.

If you have it working with Firefox can you just send me a link so I
can see what needs to be done.

Im sorry Table-row has nothing to do with the issue. The issue is the
html element will not collapse again. I know how to adjust the display
I dont know how to Collapse the element again.

Earl
Did you try the example I posted in Firefox? It works for me.

Peter

Sep 9 '06 #5
ASM
ea*******@gmail.com a écrit :
I have a small script that loads a table with some elements visiblity =
hidden and display = none. When clicking on the link it "opens" the
hidden table elements. When click on the link again it "hides" the
elements.

Now this works dandy in IE but in FireFox the element "opens" but when
you click on it again to "hide" the text in the cell disappears but the
actual element itself does not "dissappear" leaving a big blank space.

Working sample is here http://www.jhdesigninc.com/testJava.asp
It is tipicaly a misundertanding about css rules in IE.
IE needs 'block' and FireFox (and others) wants 'table-row' for rule
'display' about rows in table.

As you want to hide a TR, the best way is to undisplay it
Then to show it again you just need to give it back it's natural appearance.

Of course, your TR 'notes' has no rule to hide him in "normal" view.
It's *JS who has to* do the job ( onload = function ...)

Code Sample-----------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
[snip]

<script type="text/JavaScript">
function changeView(objChange){
var objToChge = document.getElementById(objChange).style;
objToChge.display = objToChge.display==''? 'none' : '';
}
onload = function() { changeView('notes'); };
</script>

[re-snip]
</tr>
<tr id="notes">
<td colspan="5" bgcolor="#993399"><p>some tesa safd asfd
[etc...]
</html>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 9 '06 #6
Yes Peter I have tried table-row. I will try it again and see if it
closes the table.

document.getElementById(objChange).style.display = "table-row"; does
not work in Fox which is where I am looking for the solution. In
addition it breaks IE.

I know table-row for the display I can sniff.

My quandry is how do I get the element to disappear in Fox. If you
click on it multiple times it keeps adding space and wholes. It never
collapes's

Any ideas?

Earl

Sep 9 '06 #7
Where is the link that works?

Sep 9 '06 #8

surf_doggie wrote:
Where is the link that works?
It wasn't a link. Here it is again. But if what ASM posted is true then
you should use the el.style.display = "" option instead of
el.style.display = "table-row" in the following example so it works in
firefox and ie.

Peter

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<Meta Http-Equiv="Content-Type" Content="text/html;
charset=iso-8859-1">
<titleblah-blah </title>

<script type="text/javascript">

function changeView(objChange){
var el = document.getElementById(objChange)
if (el){
if (el.style.display.toLowerCase() !== 'none'){
el.style.display = "none";
} else {
el.style.display = "table-row";
// this works too as long as the display style is not set in
a css file etc
//el.style.display = "";
}
}
}

</script>
</head>
<body>

<p>
Click on the LINK Its works in IE and Netscape but not Fox.
The window does not go to display:none and visibility:hidden
In Firefox compare IE and Firefox by clicking on the view
button multiple times in both browsers
</p>

<table width="100%" border="0" cellspacing="2" cellpadding="0"
id="clickTbl">
<tr>
<td>Bill Gordon</td>
<td>Awaiting Approval</td>
<td>Pending</td>
<td>Pending</td>
<td><a href="#" onClick="changeView('notes');return
false;">View</a></td>
</tr>
<tr id="notes" style="display:none">
<td colspan="5" bgcolor="#993399">
<p>some tesa safd asfd asddfdasdf
fasd fasfd as dfas df asdf asdf asdf as dfas df asdf asdf asdf
asdf asd asdfasda</p>
<p>asdasdfasdf</p>
<p>asdf</p>
<p>a</p>
<p>sdf </p>
</td>
</tr>
<tr>
<td>Brenda Hudson</td>
<td>Under Review</td>
<td>Pending</td>
<td>Pending</td>
<td>Cell Below Not Relevant</td>
</tr>
</table>

</body>
</html>

Sep 9 '06 #9
ASM
surf_doggie a écrit :
Yes Peter I have tried table-row. I will try it again and see if it
closes the table.

document.getElementById(objChange).style.display = "table-row"; does
not work in Fox which is where I am looking for the solution. In
addition it breaks IE.
Any ideas?
You absolutely not have to use neither 'table-row' nor 'block'.
You have to use the inverse method

1) hide : display = 'none';
2) show : display = '';

Any of your elements to hide are styled in {display:none}
JavaScript will hide what you want on loading page
Then your link or button will alternatively show / hide what was hidden

There is no other "clean" way to do.

<html>
<script type="text/javascript">
function switcher(boxId) {
var box = document.getElementById(boxId).style;
box.display = box.display==''? 'none' : '';
}
onload = function() { switcher('row');}
</script>
<a href="#" onclick="switcher('row');return false">swith row</a>
<table border=2 cellspacing=5>
<tr id="row" bgcolor="#ffffcc">
<td height=120>to see</td><td>what appends</td>
</tr><tr>
<td>something</td><td>here</td>
</tr>
</table>
</html>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 10 '06 #10
ASM:
I have to ask because I am trying to solve the issue of the block not
closing. I have heard alot about table-row. Sorry Im dense but that
will collapse the table row?

I appreciate all the help Im but I cant get the table row to collapse.

It would seem to me that it wouldnt matter if I called table-row or
block when I call .style.display = "none"; and .style.visibility =
"hidden";

In FoxFire that it would collapse the same way it does in IE.
All I am looking for is to be able to collapse the table in Fox the
same way it does in IE. Im sorry Im not getting it and you guys have it
figured out can someone tell me where I am failing?

Earl

Sep 10 '06 #11
You all have been great testing peters solution will let you know in
the am.

Thanks all

Sep 10 '06 #12
ASM
surf_doggie a écrit :
ASM:
Dear Earl Doggle Surf,

It would be better you keep in your posts some text from post you're
answering.

It is very difficult to follow what about you're speaking.

Can't you use preferences of your Mozilla Messenger ?
(somewhere it's question of news and/or forums)
I have to ask because I am trying to solve the issue of the block not
closing. I have heard alot about table-row. Sorry Im dense but that
will collapse the table row?
To hide a block or any element : visibility: hidden;
To disappear a block or an elemt : display: none;

Both actions are not same,
- 1st : un-show the element but keep place for it
- 2nd : un-display the element -no place kept

You have to decide *which one* of these two methods you want, and then
to adopt the right method for its contrario.

Revealing a hidden is quit easy : visibility: visible;

But to reveal a non displayed element is more difficult,
you need to know at what kind of element you tell :
is it of type : image, block, in-line, table, table-row etc... ?

IE, with it's approximations and it's unknowing correct css, cause
problem so we avoid to have to precise this element properties.

display off : myElement.style.display = 'none';
display back : myElement.style.display = '';

absolutely used in this order.

And switchering is obtained with :

myElement.style.display = myElement.style.display == ''?
'none' : '' ;

or in long code :

if(myElement.style.display == '') myElement.style.display = 'none';
else
myElement.style.display = '';

This method is available for all styles, of course.
I appreciate all the help Im but I cant get the table row to collapse.
Did you try the example code given in my percedent posts ?
(copy that code and paste it in your notePad and save it in html
extension, then try it in your browsers)
The last one is a very basic example I think not too much difficult to
understand.
It would seem to me that it wouldnt matter if I called table-row or
block when I call .style.display = "none"; and .style.visibility =
"hidden";
See above (it's one or other : display OR visible)

If you set style to 'none' it is none, nothing, nada, rien ...
(whatever the element is)

To style back your element
you just need to tell there is no more style added -'';
Translation : style is empty (different of nada, nothing)

In FoxFire that it would collapse the same way it does in IE.
use correct method given.
All I am looking for is to be able to collapse the table in Fox the
same way it does in IE. Im sorry Im not getting it and you guys have it
figured out can someone tell me where I am failing?
You're failling in :
- css using (and their significations)
- no easy possibility to correctly address to a table row

The way is to use the default mechanisms of browsers :
they know what are the proprieties of element called
even if they do not name them same way.
--
Stephane Moriaux et son [moins] vieux Mac
Sep 10 '06 #13
Thanks ASM I appreciate all the help the room has givin me lots of good
people here. As I suspected the issue was really silly.
is it of type : image, block, in-line, table, table-row etc... ?
Yes I now have to sniff the browser and use table-row for a correct
display but the issue of the table-row collapsing in FireFox was really
a silly mistake. To correct the issue in Firefox I changed

<tr id="notes" style="visibility:hidden; display:none;">
<td colspan="5" bgcolor="#993399"--------
TO

<tr>
<td colspan="5" bgcolor="#993399" id="notes" style="visibility:hidden;
display:none;">-----

Time to start cleaning up code and making it tighter thank you all for
your help with this.

In the future I will remember to quote ASM good point about
understanding whats going especially if your getting email
notifications

Earl


ASM wrote:
surf_doggie a écrit :
ASM:

Dear Earl Doggle Surf,

It would be better you keep in your posts some text from post you're
answering.

It is very difficult to follow what about you're speaking.

Can't you use preferences of your Mozilla Messenger ?
(somewhere it's question of news and/or forums)
I have to ask because I am trying to solve the issue of the block not
closing. I have heard alot about table-row. Sorry Im dense but that
will collapse the table row?

To hide a block or any element : visibility: hidden;
To disappear a block or an elemt : display: none;

Both actions are not same,
- 1st : un-show the element but keep place for it
- 2nd : un-display the element -no place kept

You have to decide *which one* of these two methods you want, and then
to adopt the right method for its contrario.

Revealing a hidden is quit easy : visibility: visible;

But to reveal a non displayed element is more difficult,
you need to know at what kind of element you tell :
is it of type : image, block, in-line, table, table-row etc... ?

IE, with it's approximations and it's unknowing correct css, cause
problem so we avoid to have to precise this element properties.

display off : myElement.style.display = 'none';
display back : myElement.style.display = '';

absolutely used in this order.

And switchering is obtained with :

myElement.style.display = myElement.style.display == ''?
'none' : '' ;

or in long code :

if(myElement.style.display == '') myElement.style.display = 'none';
else
myElement.style.display = '';

This method is available for all styles, of course.
I appreciate all the help Im but I cant get the table row to collapse.

Did you try the example code given in my percedent posts ?
(copy that code and paste it in your notePad and save it in html
extension, then try it in your browsers)
The last one is a very basic example I think not too much difficult to
understand.
It would seem to me that it wouldnt matter if I called table-row or
block when I call .style.display = "none"; and .style.visibility =
"hidden";

See above (it's one or other : display OR visible)

If you set style to 'none' it is none, nothing, nada, rien ...
(whatever the element is)

To style back your element
you just need to tell there is no more style added -'';
Translation : style is empty (different of nada, nothing)

In FoxFire that it would collapse the same way it does in IE.

use correct method given.
All I am looking for is to be able to collapse the table in Fox the
same way it does in IE. Im sorry Im not getting it and you guys have it
figured out can someone tell me where I am failing?

You're failling in :
- css using (and their significations)
- no easy possibility to correctly address to a table row

The way is to use the default mechanisms of browsers :
they know what are the proprieties of element called
even if they do not name them same way.
--
Stephane Moriaux et son [moins] vieux Mac
Sep 10 '06 #14
ASM
surf_doggie a écrit :
Thanks ASM I appreciate all the help the room has givin me lots of good
people here. As I suspected the issue was really silly.
>is it of type : image, block, in-line, table, table-row etc... ?
Some progress in posting :-)
Yes I now have to sniff the browser
absolutely not

You turn the problen in wrong way and never you'l really get absolute
satisfaction.
I changed TO

<tr>
<td colspan="5" bgcolor="#993399" id="notes" style="visibility:hidden;
display:none;">
And it is a very bad way to do !
How visitor with JS disabled will can see this element ?

Don't tell me he turns on his JS.
As he see nothing it can't know there would be something to see.

Last time I tell it : the element must be hide by javascript.

With bonus : show is very easy.

--
Stephane Moriaux et son [moins] vieux Mac
Sep 10 '06 #15

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

Similar topics

1
by: Nathan DeBardeleben | last post by:
This may seem wierd, and I know someone asked this question before but was told they were doing it the hard way. Unlike them, I do not have shell access to the machine where this javascript runs....
6
by: TJ | last post by:
Hello All, I posted a question a few days ago entitled "Select element with no selected options". Over the course of the discussion, RobG wrote: > This is just an example, it is not really...
3
by: Jason | last post by:
I have two applications that I wrote that use asp and javascript source files. Recently both of these applications starting acting strange on my test box. Image icons will randomly stop showing...
3
by: fbwhite | last post by:
I am having an issue (maybe two issues) in my application regarding a stylesheet not loading and I am getting Javascript Errors. If I clean out a client's temporary internet files and then browse...
4
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
6
by: kenundrum | last post by:
Hey all, I am having an issue with XML/XSLT and JavaScript in my ASP.NET page that I am creating. I first want to apologize if i placed this in the wrong category. Since there were three different...
33
by: Simon Brooke | last post by:
I'm working on a system which uses Google maps. I want the user to see a map of more or less where (s)he is in the world when (s)he first comes to the system. So the obvious thing seemed to be to...
3
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, This is an issue that happens to me and everybody else I know and I've never found a way around it. In Visual Studio (currently using 2003 but the same has happened for me in 2005 and...
1
by: a.bavdhankar | last post by:
Hi, Newbie Question: Applicable to dotnet 2.0 I am getting javasacript error message as Expected ')' but all script works fine on other machine. There is no syntax error in the script but...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
1
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.