HighDots Forums  

Piccola modifica menu a discesa

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Piccola modifica menu a discesa in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
YR
 
Posts: n/a

Default Piccola modifica menu a discesa - 10-25-2007 , 09:59 AM






Ho trovato online uno script per un menu a discesa del tipo (chiedo venia ma
userò un linguaggio elementare vista la mia totale ignoranza in materia)

- TITOLO
ci si clicca sopra ed appaiono le voci relative
- TITOLO
argomento1
argomento2
ecc.

Il codice è il seguente

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

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar =
document.getElementById("principale").getElementsB yTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar[i].className=="menu_int")
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

......mentre nella pagina html il richiamo è

<div id="principale">

<div class="titolomenu" onclick="SwitchMenu('sub1')">TITOLO1</div>
<span class="menu_int" id="sub1">
- <a href="#">argomento1</a><br>
- <a href="#">argomento2</a><br>
- <a href="#">argomento3</a>
</span>

<div class="titolomenu" onclick="SwitchMenu('sub2')">TITOLO2</div>
<span class="menu_int" id="sub2">
- <a href="#">argomento4</a><br>
- <a href="#">argomento5</a><br>

- <a href="#">Script ASP</a>
</span>

Vorrei modificare un menu in questione in modo che, al clic sul secondo
titolo, il primo rimanga aperto (e mostri tutti i suoi argomenti) e non si
chiuda.

Cosa va modificato?

Grazie mille in anticipo per ogni informazione!

--
Andrea
- - - - - - - - - - - - - - -
www.italiatibet.org
www.thehungersite.com



Reply With Quote
  #2  
Old   
_Luca_
 
Posts: n/a

Default Re: Piccola modifica menu a discesa - 03-05-2008 , 10:21 AM






YR ha scritto:
Quote:
Vorrei modificare un menu in questione in modo che, al clic sul secondo
titolo, il primo rimanga aperto (e mostri tutti i suoi argomenti) e
non >si chiuda.

Credo che tu debba solo modificare la funzione eliminando il ciclo for
che 'chiude' tutti sotto menu. Prova un pò questa versione
leggermenteroba qua:

function SwitchMenu(obj)
{
if(document.getElementById)
{
var el = document.getElementById(obj);
if(el.style.display != "block")
el.style.display = "block";
else
el.style.display = "none";
}
}


Va da se che se vuoi imparare ad usare queste funzionalità, prima o poi
ti toccherà studiarti un pò di javascritp. http://javascript.html.it
potrebbe essere un buon punto di partenza.

Buon submenuing :-)
Luca


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.