ISO HTML Help
Nov. 4th, 2007 05:11 pmI'm trying to figure out how to do an expanding list in HTML - anyone have any hints? I know what I want it to look like, but I can't conceptualize how to search for what I'm looking for.
It starts out looking like this:
- Heading One
- Heading Two
- Heading Three
- Heading Heading Four
Click on Heading One, and it looks like this:
- Heading One
- Item One
- Item Two
- Item Three
- Heading Two
- Heading Three
- Heading Heading Four
Click on Heading Two, and you get either of these:
- Heading One
- Item One
- Item Two
- Item Three
- Heading Two
- Item A
- Item B
- Item C
- Heading Three
- Heading Heading Four
or:
- Heading One
- Heading Two
- Item A
- Item B
- Item C
- Heading Three
- Heading Heading Four
no subject
Date: 2007-11-04 11:23 pm (UTC)no subject
Date: 2007-11-04 11:41 pm (UTC)no subject
Date: 2007-11-04 11:42 pm (UTC)no subject
Date: 2007-11-04 11:45 pm (UTC)no subject
Date: 2007-11-04 11:48 pm (UTC)no subject
Date: 2007-11-04 11:49 pm (UTC)no subject
Date: 2007-11-04 11:50 pm (UTC)[1] My synax is almost certainly wrong, but I think you understand my meaning...
no subject
Date: 2007-11-05 12:27 am (UTC)Thought is that you could do it with divs, make them hidden or in-line depending on what had been clicked, but default when page was loaded would have all hidden except for the top level.
no subject
Date: 2007-11-05 03:14 am (UTC)If you want to hand roll it, it's not that bad. Simply put an id tag on each ol tag for the pop out lists. Create an onclick event on the encapsulating menu. When clicked, toggle the style.visible attribute.
no subject
Date: 2007-11-05 05:15 am (UTC)function change(id)
{
identity=document.getElementById(id);
myClass = identity.className;
if (myClass == 'divHidden') {
identity.className='divShown';
} else {
identity.className='divHidden';
}
}
Add 2 entries to a style tag on your page:
.divHidden {
display: none;
}
.divShown {
display: block;
}
wrap the lists in div tags with id settings, then make a button or link and set an onClick=change(id) where id is the name of the div you want to show/hide.
ie
(a href="#" onclick="change('list1');)Heading 1(/a)
(div id="list1" class=divHidden)
1. option1
2. option2
(/div)
(a href="#" onclick="change('list2');)Heading 2(/a)
(div id="list2" class=divHidden)
1. option3
2. option4
(/div)
no subject
Date: 2007-11-05 09:28 am (UTC)For example,
However, to get what your asking for with static pages would still require about 17 pages, the code for the different top pages would be a mashup of different include statements.
On the other hand, you could fall back on an old approach that will work with any browser going back to lynx and mosaic. Write the full page and then write a table of contents at the top with links to each section below