I want to create a list of section links, which when clicked displays a list of sub-sections below. Like NorCascade.
I can use the SectionList(ar) javascript function to generate a dynamic list of sections and sub-sections, no problem this works well.
And I have a javascript function, MM_showHideLayers, which shows/hides DIV's when a link is clicked and works like this:
<a href="#" onClick="MM_showHideLayers('subsection_1','','show')">section link</a>
<div id="subsection_1" style="visibility: hidden;">
sub section 1<br>
sub section 2<br>
sub section 3<br>
sub section 4<BR>
</div>
As you can see the subsections div is hidden until the link is pressed, at which point the MM_showHideLayers function makes the DIV visible.
So I want the SectionList to display the section links with an onclick event as above and the sub-sections to be wrapped in a numbered DIV. This is not difficult. I could just modify the SectionList function slightly to include the onclick and add the DIV tags.
But... will it work, can a javascript function write javascript which will still function?
The SectionList is a loop which goes through the array of sections/subsections and print the links to screen, but if those link have a javascript onlick event will that event still work?
Thanks, K.
------------------------------------------------------
This is the code:
MM_showHideLayer function
I can use the SectionList(ar) javascript function to generate a dynamic list of sections and sub-sections, no problem this works well.
And I have a javascript function, MM_showHideLayers, which shows/hides DIV's when a link is clicked and works like this:
<a href="#" onClick="MM_showHideLayers('subsection_1','','show')">section link</a>
<div id="subsection_1" style="visibility: hidden;">
sub section 1<br>
sub section 2<br>
sub section 3<br>
sub section 4<BR>
</div>
As you can see the subsections div is hidden until the link is pressed, at which point the MM_showHideLayers function makes the DIV visible.
So I want the SectionList to display the section links with an onclick event as above and the sub-sections to be wrapped in a numbered DIV. This is not difficult. I could just modify the SectionList function slightly to include the onclick and add the DIV tags.
But... will it work, can a javascript function write javascript which will still function?
The SectionList is a loop which goes through the array of sections/subsections and print the links to screen, but if those link have a javascript onlick event will that event still work?
Thanks, K.
------------------------------------------------------
This is the code:
MM_showHideLayer function
Code:
function MM_showHideLayers() { //v6.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } obj.visibility=v; } }
Comment