Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    241

    Aggiornamento di tutte le select cambiando il valore di una

    Non so se questa sia la sezione giusta per esprimere il mio problema che definirei abbastanza comune; ho un gruppo di select legate tra loro, ognuna descrive un aspetto della persona (cognome, nome, sesso, ecc.); quando cambio la selezione in una di queste vorrei che subito cambiasse in tutte le altre (tutte le select hanno lo stesso value) tramite l'evento onchange ma non saprei come fare; ora vi mostro quello che ho provato e che non funziona:
    codice:
    <html>
      <body>
        <form action="<?echo $_SERVER['PHP_SELF'];?>" method="get">
          <table>
            <tr>
              <td>
    <?echo "<select name=\"primo\"
    onchange=\"window.location.href=('".$_SERVER['PHP_SELF']."?pettorale='+this.options[this.selectedIndex].value)>\">";?>
                  <option value="1"<?echo 1==$_GET["pettorale"]?" selected":"";?>>Uno</option>
                  <option value="2"<?echo 2==$_GET["pettorale"]?" selected":"";?>>Due</option>
                </select>
              </td>
              <td>
    <?echo "<select name=\"secondo\"
    onchange=\"window.location.href=('".$_SERVER['PHP_SELF']."?pettorale='+this.options[this.selectedIndex].value)>\">";?>
                  <option value="1"<?echo 1==$_GET["pettorale"]?" selected":"";?>>One</option>
                  <option value="2"<?echo 2==$_GET["pettorale"]?" selected":"";?>>Two</option>
                </select>
              </td>
              <td>
    <?echo "<select name=\"terzo\"
    onchange=\"window.location.href=('".$_SERVER['PHP_SELF']."?pettorale='+this.options[this.selectedIndex].value)>\">";?>
                  <option value="1"<?echo 1==$_GET["pettorale"]?" selected":"";?>>Un</option>
                  <option value="2"<?echo 2==$_GET["pettorale"]?" selected":"";?>>Deux</option>
                </select>
              </td>
            </tr>
          </table>
        </form>
      </body>
    </html>

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    241
    Risolto! c'è solo un errore di digitazione, un > in più verso la fine delle tre righe!
    Questo è il codice corretto:
    codice:
    <html>
      <body>
        <form action="<?echo $_SERVER['PHP_SELF'];?>" method="get">
          <table>
            <tr>
              <td>
    <?echo "<select name=\"primo\"
    onchange=\"window.location.href=('".$_SERVER['PHP_SELF']."?pettorale='+this.options[this.selectedIndex].value)\">";?>
                  <option value="1"<?echo 1==$_GET["pettorale"]?" selected":"";?>>Uno</option>
                  <option value="2"<?echo 2==$_GET["pettorale"]?" selected":"";?>>Due</option>
                </select>
              </td>
              <td>
    <?echo "<select name=\"secondo\"
    onchange=\"window.location.href=('".$_SERVER['PHP_SELF']."?pettorale='+this.options[this.selectedIndex].value)\">";?>
                  <option value="1"<?echo 1==$_GET["pettorale"]?" selected":"";?>>One</option>
                  <option value="2"<?echo 2==$_GET["pettorale"]?" selected":"";?>>Two</option>
                </select>
              </td>
              <td>
    <?echo "<select name=\"terzo\"
    onchange=\"window.location.href=('".$_SERVER['PHP_SELF']."?pettorale='+this.options[this.selectedIndex].value)\">";?>
                  <option value="1"<?echo 1==$_GET["pettorale"]?" selected":"";?>>Un</option>
                  <option value="2"<?echo 2==$_GET["pettorale"]?" selected":"";?>>Deux</option>
                </select>
              </td>
            </tr>
          </table>
        </form>
      </body>
    </html>

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.