/    Sign up×
Community /Pin to ProfileBookmark

showing multiple hidden rows in html table

I have a table with various text, onclick elements and images in it

I want to simulate a sub menu effect by onload hiding,say rows 2-5;7-10;12-15. That is showing rows 1;6;11.
then by clicking on a button at the end of row1 show rows 2-5;
similarly click on button end of row 6 to show 7-10; etc.
and also be able to close the expanded rows from button within their own rows.
Is this a good strategy?

my tables contain quite complex actions i.e. pass to mp3 and php download etc.
I found the script below as a simple start but i am stuck
how would the function apply to different row ids- would you use byClass instead?

<script type=”text/javascript”>

function displayRow(){
var row = document.getElementById(“captionRow”);
if (row.style.display == ”) row.style.display = ‘none’;
else row.style.display = ”;
}
</script>

<table width=”300″ border=”1″>
<tr id=”captionRow”><th>TH-1</th><th>TH-2</th><th>TH-3</th></tr>
<tr><td>cell-11</td><td>cell-12</td><td>cell-13</td></tr>
<tr><td>cell-21</td><td>cell-22</td><td>cell-23</td></tr>
</table>
<p><button onclick=”displayRow()” >Show / Hide</button></p>
</body>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@faunusauthorFeb 12.2009 — Sorry I mean the button in row 1 and or 6 and or 11 that shows the hidden rows should toggle to hide the rows again, not a different button in the hidden rows .
×

Success!

Help @faunus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...