Hiding table row(s) using (nested) <div>(s) {x-posted in c.l.javascript}

F

F. Da Costa

Following is a snippet of html in which I hide a whole table and try to
hide a single row.

Here is my question (plz don't chew my head off if its css related instead):
Why does the divTable <div> Hide/Show work but not the divRow version?

What I'm trying to do here is simultaneously hide 1 or more rows
(possibly with nested divs as well).
This would allow for an elegant an well performing base for an html base
treetable (but I guess that's not relevant).

Any suggestions appreciated.

TIA
Fermin DCG


<html>
<head>
<script>

function show(obj) {
document.getElementById(obj).style.display =
(document.getElementById(obj).style.display=='block') ? 'none': 'block';
}

</script>
</head>

<body>

<div style="display: block" id="divTable">
<table border="1">
<div style="display: block" id="divRow">
<tr><td>Hide / Show row</td></tr>
</div>
<tr><td>Do nothing row</td></tr>
</table>
</div>

<br>
<input type="button" onclick="show('divTable')" value="Hide/Show table">
<input type="button" onclick="show('divRow')" value="Hide/Show Row">

</body>
</html>
 
A

altamir

What I'm trying to do here is simultaneously hide 1 or more rows
(possibly with nested divs as well).
function show(obj) {
document.getElementById(obj).style.display =
(document.getElementById(obj).style.display=='block') ? 'none':
'block'; }
<div style="display: block" id="divTable">
<table border="1">

<div style="display: block" id="divRow">

it's incorrect. div element is not allowed here. that's why your script
isn't working.
<tr><td>Hide / Show row</td></tr>
 
F

F. Da Costa

altamir said:
why not just <table id="divTable" ...>
you don't need to put extra div element here.
Yep that's correct but that was basically there to show the difference
(and to test for myself)
it's incorrect. div element is not allowed here. that's why your script
isn't working.
Fair enough.
Is there however anything else that would allow me to 'grab' a hold of
all the 'encapsulated' objects (as they are by div) and deal with them
from that (higher) level.
Just tried it with said:
try <tr style="display: block" id="divRow"> and it should work fine
That was what I started with but I wanted to move into the direction as
described above.

Thx for the reply so far
 
L

Leif K-Brooks

F. Da Costa said:
x-posted in c.l.javascriptx-posted in c.l.javascript

No, you multi-posted. Multi-posting makes replies from each group only
go to that group, instead of each group where the message was posted.
Please cross-post instead.
 
F

F. Da Costa

Leif said:
No, you multi-posted. Multi-posting makes replies from each group only
go to that group, instead of each group where the message was posted.
Please cross-post instead.

Ah, there is a difference. I wasn't aware of that, another thing learned
today ;).
Any chance you could fill me in on how to go about *true* cross post
instead.
I'm using Moz Thunderbird (if that is relevant)

TIA
Fermin DCG
 
F

F. Da Costa

Never mind my last message (slow pickup), I figured it out.

Thx nonetheless.
 

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

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top