Ver Mensaje Individual
  #7 (permalink)  
Antiguo 03/04/2013, 16:04
summerblack
 
Fecha de Ingreso: diciembre-2012
Mensajes: 249
Antigüedad: 11 años, 4 meses
Puntos: 2
Respuesta: alguien sabe como capturar datos de una tabla?

hola amigos que pena molestar tanto, pues ya hice lo que me explicaron pero aun no doy con el chiste,

tengo 2 errores,
Notice: Undefined variable: cantidad in D:\Apache\htdocs\Desarrollos\sistemapedidos\produc tos.php on line 41
Código HTML:
Ver original
  1. <!doctype html>
  2. <meta charset="utf-8">
  3. <title>Documento sin título</title>
  4. <script type="text/javascript">
  5.   function captura_cantidad(){
  6.      
  7.     var cantidad = document.getElementsByName('cantidad');
  8.     alert(cantidad);
  9. }
  10. </head>
  11.  
  12. <?php
  13. include_once("pedido.php");
  14. $p=new Pedido;
  15. $lista= $p->consultar_productos();
  16. if (isset($_GET['cantidad']))
  17. {
  18.     $cantidad = $_GET['cantidad'];
  19. }
  20. ?>
  21. <table style="border:1px solid #ccc; color:#000;width:800px;">
  22. <tr style="background:#999900;">
  23. <td>Item</td>
  24. <td>Nombre Item<br/></td>
  25. <td>Precio<br/></td>
  26. <td>Cantidad </td>
  27. <td>Agregar</td>
  28. </tr>
  29. <?php
  30. while($row = mysqli_fetch_array($lista)){
  31.  echo "<tr>";
  32.   echo "<td>".$row['Item']."</td>";
  33.   echo "<td>".$row['NombreItem']."</td>";
  34.   echo "<td>".$row['Precio']."</td>";
  35.   echo "<td> <input type='text' onkeyup='captura_cantidad()' name='cantidad' size='2' maxlength='2'/></td>";
  36.   echo '<td><a href="carrito.php?Item='.$row['Item'].'&NombreItem='.$row['NombreItem'].'&cantidad='.$cantidad.'">Agregar</a>';
  37.   echo "</tr>";
  38.  }
  39. ?>
  40. </body>
  41. </html>


carrito.php

Código HTML:
Ver original
  1. <?php
  2. if(isset($_GET['Item']) && (isset($_GET['NombreItem']))&& (isset($_GET['cantidad'])))
  3. {
  4.     echo 'Productos: '.$_GET['Item'];
  5.     echo ' - '.$_GET['NombreItem'];
  6.     echo ' - '.$_GET['cantidad'];
  7. }
  8. ?>

y al escribir un numero en el campo cantidad me sale un alert pero con el siguiente error

[object NodeList]

de nuevo les agradeceria que me guiaran