Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2015, 05:44
MartinFernandoAndres
 
Fecha de Ingreso: febrero-2015
Mensajes: 27
Antigüedad: 10 años
Puntos: 0
Mantener valores de un select luego de submit

Gente cuando elijo una opción del select me trae los datos que quiero y hace el submit

Pero cuando se hace el submit el select vuelve al primer valor y no al elejido

Como hago para que se mantenga el valor?

Código PHP:
<?php     $xxx 0?>
        <form name="formul" method="POST" action="test.php">
            <select name='miSelect' onchange='this.form.submit()'>
            <?php
                
while ($rows $stmt->fetch()) {        
                echo 
"<option value='$id' ";
                if(
$_POST['miSelect']=='$id'
                echo 
"SELECTED";
                echo 
">";
                echo 
$titulo;
                echo 
"</option>";
                if (
$xxx == 0){
                
$selected_val "$id";
                }        
                
$xxx += 1;    
                }
            
?>
            </select>
            <br>
            <br>
                    
            <?php
            
//Muestro la id del auto seleccionado
            
if(isset($_POST['miSelect']))
            {
            
$selected_val $_POST['miSelect'];
            echo 
"La Id del auto seleccionado es: " .$selected_val;
            };
            
?>
            <noscript><input type="submit" value="Submit"></noscript>
        </form>

Última edición por MartinFernandoAndres; 11/03/2015 a las 07:13