Ver Mensaje Individual
  #33 (permalink)  
Antiguo 25/08/2008, 11:14
jrodriguez30
 
Fecha de Ingreso: abril-2008
Mensajes: 151
Antigüedad: 16 años, 11 meses
Puntos: 0
Respuesta: Recorrer tabla

<div id = "tabla1" style="width: 900px; height:420px; background-color: white; border-bottom : 1px solid #cccccc; border-left : 1px solid #cccccc ; border-widht:4px; overflow:auto;">
<?
$depto_ = $_POST['depto'];
$tipomat_ = $_POST['tipomaterial'];
$fecha_ = $_POST['fecha'];
$conn_ = mysql_connect('localhost','root','') or die(mysql_error());
$selec_ = mysql_select_db('sss') or exit();
$query_ = "select * from varsku where categoria = '$tipomat_'";
$consulta = mysql_query("$query_") or die(mysql_error());
if ((mysql_num_rows($consulta)) < 1)
{
echo "No se encontraron resultados, intentelo de nuevo";
}
else
{
?>
<center><h1 style = "color: blue">Solicitud de Utiles</center>
<center><h1 style = "color: blue">Departamento de:<?php echo $depto_?></center>
<center><h1 style = "color: blue">Fecha de Pedido:<?php echo $fecha_?></center>
<body onload="pinta()">
<?
echo "<form name = formulario action = adicionapedido.php method = get>";
echo "<TABLE BORDER = 10 id = tabla>";
echo "<TR><TH bgcolor=#C0D9D9>Fecha</th><TH bgcolor=#C0D9D9>Categoria</th><TH bgcolor=#C0D9D9>Cod</th><TH bgcolor=#C0D9D9>Descripcion</th><TH bgcolor=#C0D9D9>Unidad</th><TH bgcolor=#C0D9D9>Cantidad</th>";
while($sql = mysql_fetch_array($consulta))
{
echo "<tr>";
echo "<td>".$fecha_."</td>";
echo "<td>".$sql['subcategoria']."</td>";
echo "<td>".$sql['codigo']."</td>";
echo "<td>".$sql['descrip']."</td>";
?><td id="unidad"><input type="text" name="und" id="und"></td>
<td id="cantidad"><input type="text" name="cant" id="cant"></td> <?
echo "</tr>";
}
echo "</table>";
echo "</form>";
?></body>
<?
}
mysql_close($conn_);
?>
</div>
<div float:bottom>
<input type="button" name="adicionapedido" value="Realizar Pedido">
<input value="Ver valores de la tabla" onclick="datosTextos()" type="button" />

</div>
<?
}
?>
<?
piepagina();
?>


<script language="javascript">
function pinta()
{
cual=document.getElementById("tabla").rows;
for(a=0;a<cual.length;a++)
{
color(a);
}
}
function color(b)
{
if(b%2==0)
cual[b].style.backgroundColor="#9999FF";
else
cual[b].style.backgroundColor="white";
}
</script>

<script>
function datosTextos()
largo = document.formulario.und.length;
und = document.formulario.und;//array con todos los und
cant = document.formulario.cant;//array con todos los cant

for(i=0;i<largo;i++)
{
alert(und[i]+" "+cant[i]);//un alert por fila....
}
</script>