View Single Post
Old 10-06-2004, 11:48 AM   #4 (permalink)
downtroden
Inactive
 
downtroden's Avatar
 
Join Date: 06-19-04
Location: Illinois
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

downtroden is liked by many
Send a message via AIM to downtroden
Well... hatchet, I kinda wanted to only have 1 include file with the complete menu, but thanks. Seonewbee, vague... but thanks .

I found this script on another site and it does EXACTLY what I want only on the same page and immediately after click... which isn't what I want. Any of you Javascripters out there... could you explain what this is doing? I know it's hiding the elements outside of the div, but how?

---- top code ----

<script type="text/javascript">

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.left_nav_subcurrent{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="left_nav_subcurrent") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

</script>


---- body code ----


<!-- Keep all menus within masterdiv-->
<div class="left_nav_current" onclick="SwitchMenu('sub1')"><a href="#">Sunday</a></div>
<span class="left_nav_subcurrent" id="sub1">
<a href="#">morning show</a><br>
<a href="#">late morning show</a><br>
<a href="#">noon show</a><br>
<a href="#">afternoon show</a><br>
<a href="#">late night with...</a><br>
<br>
</span>

<div class="left_nav_current" onclick="SwitchMenu('sub2')"><a href="#">Monday</a></div>
<span class="left_nav_subcurrent" id="sub2">
<a href="#">Usage Terms</a><br>
<a href="#">DHTML FAQs</a><br>
<a href="#">Scripts FAQs</a><br>
<br>
</span>
</div>
downtroden is offline   Reply With Quote