Aca tengo como agregarlo al select, modifique algunas cosas de tu codigo porque estaban mal puestas, como un cierre del form antes de lo esperado y el orden del codigo (soy medio maniatico con eso) Tambien debes agregarles los value a los input que vayan llenos.
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)){
if($fila["titulo_practica"] == $_POST['envia']){
$selected = "selected";
}else{
$selected = "";
}
?>
<option <?php echo $selected; ?>> <?php echo $fila["titulo_practica"]; ?> </option> <?php
}
?>
</select>
<input type="hidden" name="campo1" id="campo1" onchange="ponmedatos()"/>
</p>
<p align="left">
<div id="capa_datos" style="visibility:hidden" >
<label>
<div align="left">
<span class="Estilo1">Asignatura:</span>
</div>
</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>
</p>
<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>
Suerte