Foros del Web » Creando para Internet » HTML »

SwitchMenu

Estas en el tema de SwitchMenu en el foro de HTML en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 09/05/2008, 19:35
 
Fecha de Ingreso: abril-2008
Mensajes: 11
Antigüedad: 16 años
Puntos: 0
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>
  #2 (permalink)  
Antiguo 09/05/2008, 23:56
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Re: SwitchMenu

si, pero el HTML no nos ilustra nada... por lo visto usas una funcion de Javascript, esa si ponla... please
  #3 (permalink)  
Antiguo 10/05/2008, 12:54
 
Fecha de Ingreso: abril-2008
Mensajes: 11
Antigüedad: 16 años
Puntos: 0
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>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:08.