Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/02/2010, 13:33
patricia:)
 
Fecha de Ingreso: abril-2006
Ubicación: Venezuela
Mensajes: 126
Antigüedad: 18 años
Puntos: 0
Respuesta: almacenar en variable lo seleccionado combobox

Me explico mejor, tengo un form el cual tiene 2 combobox y cada uno de ellos muestran datos de 2 tablas diferente. apenas estoy configurando el combobox de materia, lo que quiero es que al seleccionar un valor del combo lo guarde en una variable y lo muestre por pantalla.


Este es mi codigo de toda la pagina:

Código:
<? 
 if (isset ($cdcerr)){
echo "<script>window.open('index.php','_parent');</script>";
 }
?>
<!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=utf-8" />
<title>Ingreso de Materias por Docentes</title>
<style type="text/css">
<!--
#form1 table {
 color: #FFF;
 font-weight: bold;
 text-align: right;
}
-->
</style>
</head>
<table width="860" border="0" align="left">
  <tr>
    <th scope="col"><img src="fondo.jpg" width="860" height="195" /></th>
  </tr>
  <tr>
    <td height="82"><form action="controlmateria.php" method="post" name="form1" id="form1">
      <? echo $t2?>
      <table width="626" border="0" align="center">
        <tr>
          <th colspan="2" align="center" valign="top" scope="col"><input type="submit" name="cmdguar" id="cmdguar" value="Nuevo" />
            <input type="submit" name="cdcerr" id="cdcerr" value="Cerrar" onclick=<meta http-equiv="refresh" content="1; url=index.php" />
"; 
"/></th>
        </tr>
        <tr>
          <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
        <tr>
          <td width="141" bgcolor="#FF0000">Codigo Control:</td>
          <td width="475" align="left" valign="top"><input name="t1"/  /type="text" / id="t1"  /   size="10" maxlength="10" value=<?php echo $t2;?> ></td>
        </tr>
        <tr>
          <td bgcolor="#FF0000">Materia:</td>
          <td align="left" valign="top"><?
          $con=mysql_connect("localhost","root","123");
   mysql_select_db("controlestudio",$con);
           $sql="SELECT * FROM materias order by descripcion asc";
   $res=mysql_query($sql,$con);
   if(mysql_num_rows($res) == 0){
    echo "no hay datos ";
   }else{
    echo '<select name= "materia" >';
    for ($i = 0; $i <mysql_num_rows($res); $i ++) {
     $row = mysql_fetch_assoc ($res);
      echo '<option value= "'.$row["cod_materia"].'">'.$row["descripcion"].'</option>';
    $cod_mat2 = $_POST['cod_materia']; 
    echo $cod_mat2;
     
    }
    echo '</select>';
   
   }
   
          
          ?><input type="hidden" name="cod_mat" id="cod_mat" /></td>
        </tr>
        <tr>
          <td bgcolor="#FF0000">Profesor:</td>
          <td align="left" valign="top"><select name="select2" id="select2">
          </select>
            <input type="hidden" name="cod_prof" id="cod_prof" /></td>
        </tr>
        <tr>
          <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2" align="center" bgcolor="#FF0000">&nbsp;</td>
          </tr>
      </table>
      <p>&nbsp;</p>
</form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>