Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   HTML (http://www.forosdelweb.com/f4/)
-   -   SwitchMenu (http://www.forosdelweb.com/f4/switchmenu-584841/)

plan9 09/05/2008 19:35

SwitchMenu
 
Tengo este menu desplegable y quisiera saber como hacer para que pueda desplegar mas de un item por vez. El problema es que cuando quiero desplegar el segundo me colapsa el anterior.




Aqui les dejo el codigo del menu:

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><table width="186" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="186" colspan="3" align="left" valign="top"><!-- Keep all menus within masterdiv-->
<div id="masterdiv">
<div class="menutitle"><br>
</div>

<div class="menutitle" onClick="SwitchMenu('sub1')"><a href="#">seccion 1 </a><br></div>
<div class="menutitle" onClick="SwitchMenu('sub2')"><a href="#">seccion 2 </a><br></div>
<div class="menutitle" onClick="SwitchMenu('sub3')"><a href="#">seccion 3</a></div>
<div class="menutitle" onClick="SwitchMenu('sub4')"><a href="#">seccion 4</a></div>
<div class="menutitle" onClick="SwitchMenu('sub5')"><a href="#">seccion 5</a></div>

<div class="menutitle" onClick="SwitchMenu('sub6')">seccion 6</div><span class="submenu" id="sub6">
<a href="#">Nro. 1<br></a>
<a href="#">Nro. 2<br></a>
<a href="#">Nro. 3<br></a>
</span>

<div class="menutitle" onClick="SwitchMenu('sub7')">seccion 7</div>
<span class="submenu" id="sub7">
<a href="#">Nro. 1</a><br>
<a href="#">Nro. 2<br>
Nro. 3</a><br>
<br>
</span></div> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>

pateketrueke 09/05/2008 23:56

Re: SwitchMenu
 
si, pero el HTML no nos ilustra nada... por lo visto usas una funcion de Javascript, esa si ponla... please

plan9 10/05/2008 12:54

Re: SwitchMenu
 
Si disculpa, no me di cuenta.
aca va el javascript:




<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
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{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=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display ="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display= ="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="no" && document.getElementById)
window.onunload=savemenustate

</script>


La zona horaria es GMT -6. Ahora son las 07:29.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.