Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    select che se selezionata apre un'altra select

    mi servirebbe avere un form in cui ho 2 select, se seleziono ad esempio la regione mi apre la select della provincia.

    mi fate un esempio?

  2. #2

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

    Ciao.
    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">
    var 
    check false;
    function 
    createSelectmyarray )
    {
        var 
    myselect document.createElement("select");
        
    myselect.setAttribute("id""myselect");
        
    document.getElementById("frm").appendChild(myselect);
        var 
    myoption = new Array();
        for (
    i=0myarray.lengthi++)
        {
            
    myoption[i] = document.createElement("option");
            
    myoption[i].setAttribute("value"i);
            var 
    text document.createTextNode(myarray[i]);
            
    myoption[i].appendChild(text);
            
    document.getElementById("myselect").appendChild(myoption[i]);
        }
        
    start();
    }
    function 
    createSelect2(myarray)
    {
        if(
    test document.getElementById("myselect2")) 
        {
            
    document.getElementById("frm").removeChild(test);
        }
        var 
    sel document.getElementById("myselect");
        var 
    index sel.options[sel.selectedIndex].value;
        var 
    myselect2 document.createElement("select");
        
    myselect2.setAttribute("id""myselect2");
        
    document.getElementById("frm").appendChild(myselect2);
        for (
    i=0myarray[index].lengthi++)
        {
            
    document.getElementById("myselect2").options[i] = new Option(myarray[index][i],i);
            
        }
    }
    function 
    start()
    {
        var 
    myselect2 document.createElement("select");
        
    myselect2.setAttribute("id""myselect2");
        
    document.getElementById("frm").appendChild(myselect2);
        
    document.getElementById("myselect2").options[0] = new Option("------","0");
    }
    window.onload = function()
    {
        var 
    myarray = new Array("uno","due","tre");
        var 
    myarray2 = new Array();
        
    myarray2[0] = new Array("uno","due","tre");
        
    myarray2[1] = new Array("uno1","due1","tre1");
        
    myarray2[2] = new Array("uno2","due2","tre2");
        
    createSelect(myarray);
        
        var 
    sel document.getElementById("myselect");
        
    sel.onchange = function()
        {
            
    createSelect2(myarray2);
        }
    }
    </script>

    </head>

    <body>
    <form id="frm" action="../autocomplete/mypage.php" method="post" name="frm">

    </form>
    </body>
    </html> 

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

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    346
    salve a tutti, cercando tra i vari post ho trovato questo che è molto simile a quello che stò cercando. A me servirebbe che dato un select, mi elencasse sotto tutti gli utenti relazionati a quella determinata categoria ( mi seve per un invio di news letter selezionata la categoria posso eventualmente eliminare, spuntando tramite un check alcuni etenti di quella lista)
    Il codice che ho è tutto in php, ma dato che operazioni del genere devono essere svolte in js mi servirebbe una mano per impostarlo. La select che mi definisce la categoria è così impostata:
    Codice PHP:
    <select name="destinatario" class="news_input">
                                    <option value="">Seleziona il destinatario</option>
                                    <option value="prova">Prova</option>
                                    <option value="tutti">Tutti</option>
    <?
    $query2 
    "select *from table_categorie order by categoria";
    $result2 mysql_query($query2$db);
    if (
    $result2) {
         if  ( 
    mysql_num_rows($result2) > ) {
        while ( 
    $row2 mysql_fetch_array($result2)) {
    ?>                                
    <option value="<? echo $row2["id_cat"]; ?>" selected><? echo $row2["categoria"]; ?></option>
    <?        }
        }
    }
    ?>
    </select>
    </td>
    </tr>        

    <tr><td colspan="2">
    <?
    // qui in questa riga devo poter visualizzare i miei utenti con un imput check per effettuare il controllo prima dell'invio della mail, ma come faccio a visualizzare la lista in base al select precedente??
     
    query_check"select * from table_utenti where id_cat="valore della select" ";

    ?>
    </td>
    </tr>
    </table>
    grazie mille per l'attenzione

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.