Visualizzazione dei risultati da 1 a 5 su 5

Discussione: function

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929

    function

    ciao a tutti,
    ho associato ad una select un piccolo controllo

    codice:
    <select name="myselect" class="questo_input" id="myselect" onChange="document.frm('textmyselect').value=this.options[this.selectedIndex].text;if(this.options[this.selectedIndex].value=='09'){alert('ciao')}">
    adesso sto tentando di trasformarla in una funzione

    codice:
    function foto(){
    var f=document.frm('textmyselect');
    f.value=this.options[this.selectedIndex].text;
    	if(this.options[this.selectedIndex].value=='09'){
    		alert('ciao')
    	}
    
    }
    ma sfortunatamente .... cosi non vā....

    io vorrei che oltre al messaggio di alert la pagina si aggiornasse, passando in location il valore della select.
    Mi sapreste dare una mano..... grazie mille

  2. #2

    ............

    Ciao.
    Puoi provare questo:
    Codice PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"
    >
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <
    script language="JavaScript" type="text/JavaScript">
    function 
    displayInfo()
    {
    var 
    sel document.getElementById("myselect");
    var 
    query sel.options[sel.selectedIndex].value;
    //se la vuoi con get 
    var page escape("test3.htm?page="+query);
    alert("ciao");
    window.location page;
    }
    </script>


    </head>

    <body>
    <form action="formaction" method="post">
    Methods in the DOM: 
    <select id="myselect" name="selection" onChange="displayInfo()">
    <option value="attributes">Attributes</option>
    <option value="tree">Traversing the Tree</option>
    <option value="god">ting and destroying nodes</option>
    </select>
    </form> 
    </body>
    </html> 
    se ti occorre non intrusivo posta.


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    ho fatto cosi:
    codice:
    <html> 
    <head> 
    <title>CARICA IMMAGINE</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <script language="JavaScript" type="text/JavaScript"> 
    function displayInfo() { 
    	var sel = document.getElementById("myselect"); 
    	var query = sel.options[sel.selectedIndex].value; 
    		if (query == "3.jpg"){
    			var page = escape("test immagine.htm?page="+query); 
    			alert("č la terza jpg"); 
    		}else{
    			var page = escape("test immagine.htm?page="+query); 
    		}
    	window.location = page; 
    } 
    </script> 
    </head> 
    <body> 
    <select id="myselect" name="selection" onChange="displayInfo()">
      <option value="00"></option>
      <option value="1.jpg">PRIMA</option>
      <option value="2.jpg">SECONDA</option>
      <option value="3.jpg">TERZA</option>
    </select>
    </body> 
    </html>
    ed č perfetto, l'unica cosa che vorrei e che al refresh della pagina rimanesse selezionata la scelta effettuata, e poi č anche possibile mantenere la location precedente?

    Grazie mille

  4. #4

    .........

    Ciao.
    refresh della pagina rimanesse selezionata la scelta effettuata
    solo con js non saprei cosa inventarmi con
    PHP si potrebbe provare passando con un post
    o get al value della select ma non ho mai
    provato per altro puoi provare con history.


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    per la location ho risolto cosi

    codice:
    <script language="JavaScript" type="text/JavaScript"> 
    function displayInfo() { 
    	var str = window.location.search.substr(1);
    	var param = str.split(/\&/);
    	var sel = document.getElementById("myselect"); 
    	var query = sel.options[sel.selectedIndex].value; 
    		if (query == "03"){
    			alert("č la terza jpg"); 
    		}
    	location="test immagine.php?"+param[0]+"&page="+query;
    } 
    </script>
    mentre per la selezione ho usato php
    Codice PHP:
    <option value="01" <?php if ($_GET['page'] == 01 && $_GET['page'] != '') {echo "SELECTED";} ?>>prima</option>
    grazie mille

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.