• Home
  • Forum
  • Fare Web
  • Javascript

js

  • Creatore Discussione Creatore Discussione naturalmedia
  • Data di inizio Data di inizio 4 Nov 2003
N

naturalmedia

Nuovo Utente
22 Ott 2003
3
0
0
  • 4 Nov 2003
  • #1
hi guy , we try to do a jump menu, the script follow

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>

but we whant a link opened in a new window

<select name="sport" id="select2" onChange="MM_jumpMenu('self',this,0)">
we try to change in _blank or _parent . but not work some one now how to do this ????
tnk mate for your support
 

lukeonweb

Utente Attivo
5 Mar 2003
5.175
13
38
47
Napoli
www.lucaruggiero.it
  • 4 Nov 2003
  • #2
Hi, try the following code

PHP:
function JumpMenu(links) {
    //Crea un link all'indice della select selezionato
    location.href = links[links.selectedIndex].value;
}

//Crea la tabella di dati contenente le voci delle possibili opzioni
var voci = new Array();
    voci[0] = "Pagina 1";
    voci[1] = "Pagina 2";
    voci[2] = "Pagina 3";
    voci[3] = "Pagina 4";
    voci[4] = "Pagina 5";
//Crea la tabella di dati contenente i link alle rispettive voci delle opzioni

var link = new Array();
    link[0] = "pagina1.htm";
    link[1] = "pagina2.htm";
    link[2] = "pagina3.htm";
    link[3] = "pagina4.htm";
    link[4] = "pagina5.htm";

//Crea la struttura Html della select, all'evento onChange lancia la funzione
document.write("<select onChange=JumpMenu(this)>");
document.write("<option value=#>Jump to...</option>");

//Esegue un ciclo ed estende tutte le voci del menu con i relativi valori
for(i=0; i<5; i++) {
    document.write("<option value=" + link[i] + ">" + voci[i] + "</option>");
}

document.write("</select>");

If you wanna open the page in a new window, you just have to replace this line

location.href = links[links.selectedIndex].value;

with this

window.open(links[links.selectedIndex].value);

Bye
 
Devi accedere o registrarti per poter rispondere.
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • Javascript
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?