naciostars, aquí va el código completo desde el inicio de la pagina (con javascript) para después pasarla con php a otro que hace solo una consulta a la base de datos y extraigo la información.
Código PHP:
Ver original<?php
include"../../validacion/sesion_valida.php";
include"../../validacion/conexion.php";
include"querys.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=iso-8859-1" />
<title>Plataforma Control Inventario</title>
<script src="agregar.js" language="JavaScript"> </script>
<script>
function validador(){
var desde = document.getElementById("desde").value
var hasta = document.getElementById("hasta").value;
if(desde ==""){
alert("Tiene que seleccionar un valor en el campo DESDE de la serie ");
return;
}
if(hasta ==""){
alert("Tiene que seleccionar un valor en el campo HASTA");
return;
}
document.getElementById("form1").submit();
}
</script>
<link href="../estilos/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contenedor-principal">
<h1 class="titulo-mostrar">Control </h1>
<h2 class="titulo">Modulo de Control</h2>
<h5 class="caja-izquierda"><a href="../menu.php">Volver</a><span class="forma"></span></h5>
<hr />
<br />
<h4 class="sub-titulo">Modulo de Despacho </h4>
<br />
<form action="previa_despacho.php" method="post" enctype="application/x-www-form-urlencoded" target="_self">
<h5 class="titulo">Informacion Requerida para el envío Equipamiento</h5>
<table class="tabla">
<tr>
<th class="relleno">Ticket</th> <th class="relleno">Tenico</th> <th class="relleno">Validado Por</th>
<th class="relleno">Desde</th> <th class="relleno">Desde</th>
</tr>
<tr>
<td><input type="text" name="ticket" id="ticket" autocomplete="off" size="14" /></td>
<td><input type="text" name="revisado" required="required" id="revisado" autocomplete="off" size="30" /></td>
<td><input type="text" name="validador" id="validador" required="required" autocomplete="off" size="30" /></td>
<td><label for="desde"></label>
<select name="desde" id="desde" class="dropb">
<option value="">Seleccione Origen</option>
?>
<option class="formato-option" value="<?php echo $show_origen1['0']?>"><?php echo $show_origen1['1']?></option>
<?php } ?>
</select></td>
<td><label for="hasta"></label>
<select name="hasta" id="hasta" class="dropb">
<option value="">Seleccione Destino</option>
?>
<option class="formato-option" value="<?php echo $show_hasta1['0']?>"><?php echo $show_hasta1['1']?></option>
<?php } ?>
</select></td>
</tr>
</table>
<br />
<!--<h5 class="titulo">Ingrese los datos del Hardware</h5>-->
<fieldset id="fiel"><input type="button" value="Agregar Hardware" onclick="crear(this)" /></fieldset></th>
<br />
<div id="centra-tabla">
<table class="tabla">
<tr> <th> <input type="submit" name="submit_asignacion" id="submit_asignacion" value="Validar Informacion" /> </th></tr>
</div>
</form>
</div>
</body>
</html>
Codigo java script que me repite el input es el siguiente
Código Javascript
:
Ver originalnum=0;
function crear(obj) {
num++;
fi = document.getElementById('fiel'); // 1
contenedor = document.createElement('div'); // 2
contenedor.id = 'div'+num; // 3
fi.appendChild(contenedor); // 4
ele = document.createElement('input'); // 5
ele.type = 'text'; // 6
ele.name = 'serie[]'; // 6
ele.autocomplete = 'off'; // 6
ele.placeholder = 'Serie del Equipo'; // 6
ele.size = '25';
ele.required = 'required';
contenedor.appendChild(ele); // 7
ele = document.createElement('input'); // 5
ele.type = 'button'; // 6
ele.value = 'Borrar'; // 8
ele.name = 'div'+num; // 8
ele.onclick = function () {borrar(this.name)} // 9
contenedor.appendChild(ele); // 7
}
function borrar(obj) {
fi = document.getElementById('fiel'); // 1
fi.removeChild(document.getElementById(obj)); // 10
}
function borraDesasignacion(obj) {
fi = document.getElementById('desasignacion'); // 1
fi.removeChild(document.getElementById(obj)); // 10
}
y Aqui va el php que toma los datos y para mostrar los datos de la serie ingresada
Código PHP:
Ver original<?php
include"../../validacion/sesion_valida.php";
include"../../validacion/conexion.php";
include"querys.php";
$series = $_POST['serie'];
$numero = $lote_numero['0'];
}
//$series = array();
//phpinfo();
$cantidad = count($series);
echo $show_info['0'];
}
$cont= $cantidad;
echo $cantidad."<br>";
$i=0;
while ($i<$cont) {
//$cadena="";
$cadena= $query_equipo.$series[$i];
echo $cadena."<br>";
echo "cadena".$consulta_cadena."<br>";
$i=$i+1;
}
?>
<!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=iso-8859-1" />
<title>Plataforma Control de Inventario</title>
<link href="../estilos/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contenedor-principal">
<h1 class="titulo-mostrar">Control </h1>
<h3 class="titulo">Modulo de Despacho </h3>
<h5 class="caja-izquierda"><a href="../menu.php">Volver al Menu</a><span class="forma"></span></h5>
<hr />
<br />
<h5 class="titulo">Informacion del Hardware para ser enviado a la Correctiva</h5>
<form action="envio_reparacion.php" name="form1" enctype="application/x-www-form-urlencoded" id="form1" target="_self" method="post" >
<div id="centra-tabla">
<table class="tabla">
<tr>
<th class="relleno">Tipo</th> <th class="relleno">Serie</th> <th class="relleno">Rotulo</th> <th class="relleno">Modelo</th> <th class="relleno">Num Lote</th> <th class="relleno">Fecha</th> <th class="relleno">Estado</th> <th class="relleno">Desde</th>
<th class="relleno">Hasta</th> <th class="relleno">Validado por</th> <th class="relleno">Revisado por</th>
</tr>
<?php
$query_equipo1 = $query_equipo."'".$serie1."'";
$consulta_equipo1 = mssql_query($query_equipo1,$conexion);
<tr>
<td><input type="text" name="tipo[]" id="tipo" value="<?php echo $info_equipo1['0'] ?>" size="11" readonly="readonly" /></td>
<td><input type="text" name="serie[]" id="serie" value="<?php echo $info_equipo1['1'] ?>" size="14" readonly="readonly" /></td>
<td><input type="text" name="rotulo[]" id="rotulo" value="<?php echo $info_equipo1['2'] ?>" size="14" readonly="readonly" /></td>
<td><input type="text" name="modelo[]" id="modelo1" value="<?php echo $info_equipo1['3'] ?>" size="22" readonly="readonly" /></td>
<td><input type="text" name="num_lote[]" value="<?php echo $numero ?>" size="7" id="num_lote1" readonly="readonly" /></td>
<td><input type="text" name="fecha[]" id="fecha" value="<?php echo $info_equipo1['4'] ?>" size="23" readonly="readonly" /></td>
<td><input type="text" name="estado[]" size="18" value="<?php echo $info_equipo1['5'] ?>" id="estado" readonly="readonly" /></td>
<td><input type="text" name="validado" readonly="readonly" value="<?php echo $validado ?>" size="23" /></td>
<td><input type="text" name="revisado" readonly="readonly" value="<?php echo $revisado ?>" size="23" /></td>
</tr>
<?php }//cierro while equipo
}?>
</table>
<table class="tabla">
<<tr><th><br /></th>
<th> <input type="button" value="Despachar Hardware" onclick="validador()" /></th></tr>
</table>
</div>
</form>
</div>
</body>
</html>