Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/02/2016, 12:02
calel_leon
 
Fecha de Ingreso: febrero-2016
Mensajes: 48
Antigüedad: 8 años, 2 meses
Puntos: 0
Respuesta: Obtener variable desde un select dinamco

Este es el código del formulario

Código HTML:
<?php
require_once("conexion.php");
?>
<!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>RUTA Control</title>
<link href="css/estilos_basicos.css" rel="stylesheet" type="text/css" />
<link href="css/textos.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div id="principal">
  <div id="encabezado"><img src="imagenes/logo ruta.png" width="900" height="148" alt="logo" /></div>
  <div id="menu"><img src="imagenes/boton_00.gif" width="225" height="46" alt="oo" /><img src="imagenes/boton_00.gif" width="225" height="46" /><img src="imagenes/boton_00.gif" width="225" height="46" /><img src="imagenes/boton_00.gif" width="225" height="46" /></div>
  <div id="contenido">
  	<div class="texto">
  	  
  	    <h1>Ingresar Nueva Orden de Trabajo</h1>
  	    <form id="form1" name="form1" method="post" action="ot.php">
  	      <table width="600" border="1">
  	        <tr>
  	          <td width="150">Actividad</td>
  	          <td width="150"> 
                  <label for="actividad">
                	<?php
					$sql=mysql_query("SELECT actividad FROM actividad ",$con);
					?>
					<select name="activ" onchange="pedirDatos()" >
					<?php
					while($row = mysql_fetch_array($sql)){
					echo "<option value=\"".$row['actividad']."\">".$row['actividad']."</option> \n";
					}
				?>
				</select>
                </label>
              </td>
  	          <td width="150">Sector</td>
  	          <td width="150">
              	<label for="sector">
                	<?php
					$sql2=mysql_query("SELECT nombre FROM sector ORDER BY Nombre ASC",$con);
					?>
					<select name="lista" onchange="pedirDatos()" >
					<?php
					while($row = mysql_fetch_array($sql2)){
					echo "<option value=\"".$row['nombre']."\">".$row['nombre']."</option> \n";
					}
					?>
					</select>                
                </label>
              </td>
            </tr>
  	        <tr>
  	          <td>Cuartel</td>
  	          <td>
                 <label for="cuartel">
                	<?php
					$sql3=mysql_query("SELECT nombre FROM cuartel ORDER BY Nombre ASC",$con);
					?>
					<select name="lista" onchange="pedirDatos()" >
					<?php
					while($row = mysql_fetch_array($sql3)){
					echo "<option value=\"".$row['nombre']."\">".$row['nombre']."</option> \n";
					}
					?>
					</select> 
                </label>
              </td>
  	          <td>Fecha de Inicio</td>
  	          <td><label for="fechainicio"></label>
              <input type="text" name="fechainicio" id="fechainicio" /></td>
            </tr>
  	        <tr>
  	          <td>Costo</td>
  	          <td><label for="costo"></label>
              <input name="costo" type="text" id="costo" value="0" /></td>
  	          <td>Trabajadores</td>
  	          <td><label for="trabajadores"></label>
              <input name="trabajadores" type="text" id="trabajadores" value="0" /></td>
            </tr>
  	        <tr>
  	          <td>Producto</td>
  	          <td colspan="3">
              	<label for="producto">
                	<?php
					$sql4=mysql_query("SELECT nombre FROM producto ORDER BY Nombre ASC ",$con);
					?>
					<select name="lista" onchange="pedirDatos()" >
					<?php
					while($row = mysql_fetch_array($sql4)){
					echo "<option value=\"".$row['nombre']."\">".$row['nombre']."</option> \n";
					}
					?>
					</select>
                </label>
              </td>
            </tr>
  	        <tr>
  	          <td>Comentario</td>
  	          <td colspan="3"><label for="comentario"></label>
              <textarea name="comentario" id="comentario" cols="55" rows="5"></textarea></td>
            </tr>
  	        <tr>
  	          <td colspan="4"> <center><input type="reset" name="button" id="button" value="Limpiar" /> <input type="submit" name="button2" id="button2" value="Enviar" /> </center></td>
            </tr>
          </table>
      </form>
  	    <p>&nbsp; </p>
  	</div>
   
  </div>
  <div id="pie">Ruta Control</div>
</div>
</body>
</html> 

Éste es el código de la pagina que recibe el formulario

Código HTML:
<?php
require_once("conexion.php");

$activ = $_POST["row"];
$sect = $_POST["row"];
$cuart = $_POST["row"];
$fechini = $_POST["fechainicio"];
$cost = $_POST["costo"];
$traba = $_POST["trabajadores"];
$prod = $_POST["row"];
$comen = $_POST["comentario"];

echo "\nActividad :  $activ";
echo "\nSector : $sect";
echo "\nCuartel : $cuart";
echo "\nFecha Inicio : $fechini";
echo "\nCosto : $cost";
echo "\nTrabajadores : $traba";
echo "\nProducto : $prod";
echo "\nComentario : $comen";
?> 
Y esta es la respuesta que arroja el formulario al ser enviado a la pagina que procesara la informacion.

Código HTML:
Notice: Undefined index: row in C:\xampp\htdocs\RUTA2\ot.php on line 4

Notice: Undefined index: row in C:\xampp\htdocs\RUTA2\ot.php on line 5

Notice: Undefined index: row in C:\xampp\htdocs\RUTA2\ot.php on line 6

Notice: Undefined index: row in C:\xampp\htdocs\RUTA2\ot.php on line 10
Actividad : Sector : Cuartel : Fecha Inicio : 22-04-2016 Costo : 200 Trabajadores : 50 Producto : Comentario : todos los arboles
si no recibe las variables, no puedo guardaras en la base de datos.