Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di erialo
    Registrato dal
    Mar 2011
    Messaggi
    21

    Radio button che si resetta al submit

    Ciao forum ho un problema con i radio button.
    Ho due radio, Soci e Contribuenti.
    Al load della pagina, di default è selzionato "Soci", una volta compilato il form e selezionato per esempi "Contribuenti", se rimango nella stessa pagina perchè c'è qualche messaggio di errore, la sezezione del radio si riporta su Soci.... come sistemo il codice?
    Mi aiutereste?
    Per favoreeee?

    codice:
        
    <input id="opzione1" type="radio" checked="checked" name="scelta" value="valore1" />
         <label for="opzione1">Socio </label>
    <input id="opzione2" type="radio" name="scelta" value="valore2" />
         <label for="opzione2">Contribuente </label>

  2. #2
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,505
    Ammesso che invii ii dati tramite post
    Codice PHP:
    <input id="opzione1" type="radio" checked="checked" name="scelta" value="valore1" <?php if(isset($_POST['scelta']) && $_POST['scelta'] == "valore1") echo 'checked="checked"'?> />
         <label for="opzione1">Socio </label>
    <input id="opzione2" type="radio" name="scelta" value="valore2" <?php if(isset($_POST['scelta']) && $_POST['scelta'] == "valore2") echo 'checked="checked"'?> />
         <label for="opzione2">Contribuente </label>

  3. #3
    Utente di HTML.it L'avatar di erialo
    Registrato dal
    Mar 2011
    Messaggi
    21
    Quote Originariamente inviata da Alhazred Visualizza il messaggio
    Ammesso che invii ii dati tramite post
    Codice PHP:
    <input id="opzione1" type="radio" checked="checked" name="scelta" value="valore1" <?php if(isset($_POST['scelta']) && $_POST['scelta'] == "valore1") echo 'checked="checked"'?> />
         <label for="opzione1">Socio </label>
    <input id="opzione2" type="radio" name="scelta" value="valore2" <?php if(isset($_POST['scelta']) && $_POST['scelta'] == "valore2") echo 'checked="checked"'?> />
         <label for="opzione2">Contribuente </label>
    Ciao grazie...
    grazie mille... ma sbaglio qualche altra cosa... scusa ma è la mia prima app php!
    Se posto il codice di tutta la pagina dareste un'occhiata?
    Per favore...
    Ci sbatto la testa da giorni
    codice:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Registrazione online</title>
    
        <style type="text/css">
        span.opt2 {
            display: none;
        }
    
        span.opt3 {
            display: none;
        }
    
        span.opt4 {
            display: none;
        }
    
        span.opt5 {
            display: none;
        }
        
        #opzione1:checked ~ span.opt1,
        #opzione1:checked ~ span.opt3,
        #opzione1:checked ~ span.opt5,
        #opzione2:checked ~ span.opt2,
        #opzione2:checked ~ span.opt4 {
            display: block;
        }
        </style>
    </head>
    
    <body>
    <table width="695" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#ACC8E3">
      <tr>
        <td height="146" valign="top" bordercolor="#D0ECB2"><h1>Nuove iscrizioni</h1>
        </td>
      </tr>
      <tr>
        <td height="668" valign="top" bordercolor="#A2CF7E"> <form id="form1" name="form1" method="post" action="registra_tesserato.php">
        <table width="650" border="0" cellpadding="3" cellspacing="0" bgcolor="#F5F5F5">
        <?php
            $rep = isset($_GET["rep"]) ? $_GET["rep"] : '';
            $errore="";
            if($rep==2) $errore="Formato Email non valido!";
            else if($rep==1) $errore="Il Campo Nome deve contenere almeno di 3 caratteri";
            else if($rep==3) $errore="Il Campo Cognome deve contenere almeno di 3 caratteri";
            else if($rep==4) $errore="Codice Fiscale Errato";
            else if($rep==5) $errore="Il Campo Indirizzo non può essere vuoto!";
            else if($rep==6) $errore="Il Campo Comune non può essere vuoto!";
            else if($rep==7) $errore="Il Campo email non può essere vuoto!";
            else if($rep==9) $errore="Il Campo telefono  può essere solo numerico!";
            else if($rep==10) $errore="Il Campo Denominazionedeve non può essere vuoto";
            
            
            
            $denominazione = isset($_GET["denominazione"]) ? $_GET["denominazione"] : '';
            $mail = isset($_GET["mail"]) ? $_GET["mail"] : '';
            $nome = isset($_GET["nome"]) ? $_GET["nome"] : '';
            $cognome = isset($_GET["cognome"]) ? $_GET["cognome"] : '';
            $indirizzo = isset($_GET["indirizzo"]) ? $_GET["indirizzo"] : '';
            $comune = isset($_GET["comune"]) ? $_GET["comune"] : '';
            $provincia = isset($_GET["provincia"]) ? $_GET["provincia"] : '';
            $telefono = isset($_GET["telefono"]) ? $_GET["telefono"] : '';
            $cod_fiscale = isset($_GET["cod_fisc"]) ? $_GET["cod_fisc"] : '';
    
        ?>
            
            
         <tr>
            <td width="196"></td>
            <td width="442"><?php echo $errore;?></td>
          </tr>
        <input id="opzione1" type="radio" checked="checked" name="tipo" value="0" <?php if(isset($_GET['tipo']) && $_GET['tipo'] == "0") echo 'checked="checked"'; ?> />
         <label for="opzione1">Socio </label>
    <input id="opzione2" type="radio" name="tipo" value="1" <?php if(isset($_GET['tipo']) && $_GET['tipo'] == "1") echo 'checked="checked"'; ?> />
         <label for="opzione2">Contribuente </label>
                    <br><br>
                    
                        <?php echo $tipo; ?>
        <tr>
            <span class="opt2">Denominazione: <input type="text" name="denominazione" id="denominazione" maxlength="100" value="<?php echo $denominazione;?>" /></span>
          </tr>        
          <tr>
            <span class="opt1 opt2 opt3">Nome <input name="nome" type="text" id="nome" maxlength="20" value="<?php echo $nome;?>"></span>
          </tr>
          <tr>
           <span class="opt1 opt2 opt3">Cognome <input type="text" name="cognome" id="cognome" maxlength="20" value="<?php echo $cognome;?>" /></span>
          </tr>
          <tr>
            <span class="opt5">Luogo di nascita <input name="luogo_nascita" type="text" id="luogo_nascita" maxlength="40" value="<?php echo $luogo_nascita;?>" /></span>
          </tr>
          <tr>
            <span class="opt5">Data di nascita <input name="data_nascita" type="text" id="data_nascita" maxlength="40" value="<?php echo $data_nascita;?>" /></span>
          </tr>
            
    
          <tr>
            <span class="opt3">Codice Fiscale <input name="cod_fiscale" type="text" id="cod_fiscale" maxlength="16" value="<?php echo $cod_fiscale;?>" /></span>
          </tr>
           <tr>
            <span class="opt4">Partita IVA <input name="p_iva" type="text" id="p_iva" maxlength="11" value="<?php echo $p_iva;?>" /></span>
          </tr>
          <tr>
            <td>Provincia</td>
            <td><input name="provincia" type="text" id="provincia" maxlength="2" value="<?php echo $provincia;?>" /></td>
          </tr>
          <tr>
            <td>Comune</td>
            <td><input name="comune" type="text" id="comune" maxlength="20" value="<?php echo $comune;?>" /></td>
          </tr>
          <tr>
            <td>CAP</td>
            <td><input name="cap" type="text" id="cap" maxlength="10" value="<?php echo $cap;?>" /></td>
          </tr>
          <tr>
            <td>Indirizzo</td>
            <td><input name="indirizzo" type="text" id="indirizzo" maxlength="60" value="<?php echo $indirizzo;?>" /></td>
          </tr>
           <tr>
            <td>Email</td>
            <td><input name="email" type="text" id="email" maxlength="40" value="<?php echo $mail;?>" /></td>
          </tr>
           <td>Cellulare</td>
            <td><input name="cellulare" type="text" id="cellulare" maxlength="20" value="<?php echo $cellulare;?>" /></td>
          </tr>
          <tr>
            <td>Telefono</td>
            <td><input name="telefono" type="text" id="telefono" maxlength="20" value="<?php echo $telefono;?>" /></td>
          </tr>
          <tr>
    
          <tr>
            <td>Quota Associativa </td>
            <td><select name="quota">
                 <option value="35">Nuovo Tesseramento - € 35.00</option>
                 <option value="30">Rinnovo - € 30.00</option>
            </select>        </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit" value="Prosegui" /></td>
          </tr>
        </table>
         
    
        </form>    </td>
    
      </tr>
    </table>
    </body>
    </html>

  4. #4
    ciao, io ho il tuo stesso problema..solo che creo le varie opzioni da database..tu come hai risolto?

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.