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"> </th>
</tr>
<tr>
<th scope="row"><span class="Estilo1">Seleccione la práctica que desee y el kit de práctica que necesitaría para su realización </span></th>
</tr>
<tr>
<th scope="row"> </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);
$consulta= mysql_query("SELECT cod_practica,asignatura,titulo_practica from practica");
$numero_registros=mysql_num_rows($consulta);
mysql_close ($link);
?>
<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"> <span class="Estilo1">Asignatura:</span> <span class="Estilo1">
</label>
<?php
$campo_busqueda= $_POST['campo1'];
$link=mysql_connect("localhost","root","");
mysql_select_db("laboratorio",$link);
$consulta= mysql_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"
?> <span class="Estilo1">Número Alumnos: </span><?php
echo "<input name='alumnos' type='text' id='alumnos' disabled='true' size='3' value='$row[1]'>\n" ?>
<span class="Estilo1">Número Puestos: </span><?php
echo "<input name='alumnos' type='text' id='puestos' disabled='true' size='3' value='$row[2]'>\n" ?>
</div>
</div>
<p> </p>
<p> </p>
</fieldset>
</form>
*</th>
</tr>
<tr>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
</tr>
</table>
</body>