Ver Mensaje Individual
  #19 (permalink)  
Antiguo 17/12/2007, 12:44
Rebe22
 
Fecha de Ingreso: octubre-2006
Mensajes: 128
Antigüedad: 17 años, 7 meses
Puntos: 1
Pregunta Re: Recoger el valor de una variable oculta

a ver este es el código entero que tengo en la página pero claro...al recargar la página por el dichoso submit... me machaca y no se muestra la capa... ¿como pongo la capa y donde la pongo y como recupero el valor del select?

Dios q estrés...muchísimas gracias



Código PHP:
<script language="javascript">

function datos(){
var variable = document.getElementById('practica');
         valor = variable.options[variable.selectedIndex].text;

    if (variable.selectedIndex!='0'){

    var index=document.forms.formulario.practica.selectedIndex;
     document.getElementById("campo1").value=valor;
     document.forms.formulario.submit();
     document.getElementById("capa_datos").style.visibility = "visible";


    }else{
      document.getElementbyId("alumnos").value='';    
     document.getElementById("capa_datos").style.visibility = "hidden";
    }
    
}

</script>
</head>

<body>
<table width="100%" border="0">
  <tr>
    <th scope="col">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row"><span class="Estilo1">Seleccione la pr&aacute;ctica que desee y el kit de pr&aacute;ctica que necesitar&iacute;a para su realizaci&oacute;n </span></th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">
    <form method="post" name="formulario">
      <fieldset style="border:#000066">
        <legend>Datos del kit</legend>
             <p align="left">
             
             
             <?php  
            $link
=mysql_connect("localhost","root",""); 
            
mysql_select_db("laboratorio",$link); 
            
$consultamysql_query("SELECT cod_practica,asignatura,titulo_practica from practica"); 
            
$numero_registros=mysql_num_rows($consulta);
            
mysql_close ($link);
            
            
?>
            &nbsp;&nbsp;&nbsp;&nbsp;<span class="Estilo1">Seleccione la práctica:</span>
            <select name="envia" onchange="datos()" id="practica">
                    <option>Seleccionar </option>
                <?php
            
while ($fila mysql_fetch_assoc($consulta)) {
                
?>
                    <option> <?php echo $fila["titulo_practica"]; } ?></option>
          </select>
          <input type="hidden" name="campo1" id="campo1" onchange="ponmedatos()"/>
      </form>

             <p align="left">
             <div id="capa_datos" style="visibility:hidden" >
               <label>
               <div align="left">&nbsp;&nbsp;&nbsp; <span class="Estilo1">Asignatura:</span> <span class="Estilo1">
                 </label>
                 <?php 
                 
                     $campo_busqueda
$_POST['campo1'];
                     
$link=mysql_connect("localhost","root",""); 
                    
mysql_select_db("laboratorio",$link); 
                    
$consultamysql_query("SELECT asignatura,numero_alumnos,numero_puestos from practica where titulo_practica='$campo_busqueda'");
                    
$row mysql_fetch_row($consulta);
                    echo 
"<input name='asignatura' type='text' id='asignatura' disabled='true' size='30' value='$row[0]'>\n"
                    
                 
?> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Estilo1">N&uacute;mero Alumnos: </span><?php 
                     
echo "<input name='alumnos' type='text' id='alumnos' disabled='true' size='3' value='$row[1]'>\n" ?>
                    &nbsp;&nbsp;&nbsp;&nbsp;<span class="Estilo1">N&uacute;mero Puestos: </span><?php 
                     
echo "<input name='alumnos' type='text' id='puestos' disabled='true' size='3' value='$row[2]'>\n" ?>
               </div>
        </div>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      </fieldset>
          
    </form>
    
    *</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
  </tr>
</table>

</body>