Advertisement
AMERISA123

Untitled

May 25th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <html>
  2. <?php
  3. include ("conexion.php");
  4. $productos= "SELECT codigo,descripcion, precioventa,existencia, imagen FROM productos";
  5. ?>
  6. <head>
  7. <title>Formulario</title> .
  8. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  9. </head>
  10. <body>
  11. <form method="post" id="myForm">
  12. <table class="default" border="1">
  13. <caption>Productos a la Venta</caption>
  14. <tr>
  15. <th> Código</th>
  16. <th> Descripción</th>
  17. <th> Imagen</th>
  18. <th> Existencia</th>
  19. <th> Precio Unitario</th>
  20. <th> Ingrese Cantidad</th>
  21. <th> Subtotal</th>
  22. </tr>
  23.  
  24. <?php
  25. $resultado =mysqli_query($conexion, $productos);
  26. while($row=mysqli_fetch_array($resultado)){
  27. ?>
  28.  
  29. <tr>
  30. <td> <?php echo $row["codigo"];?></td>
  31. <td> <?php echo $row["descripcion"];?></td>
  32. <td> <img width="100" src= "imagenes/<?php echo $row['imagen'];?>"></td>
  33. <td> <?php echo $row["existencia"];?></td>
  34. <td> <input id= "precio" value="<?php echo $row["precioventa"];?>" disabled> </td>
  35. <td><input type="number" id="cantidad" min="0" max="<?php echo $row["existencia"];?>" size="1" > <input type="submit" value="Agregar" id="boton"></td>
  36. <td id="resultado" >
  37.  
  38. </td>
  39. <?php }mysqli_free_result($resultado);?>
  40. </tr>
  41.  
  42. </table>
  43.  
  44.  
  45.  
  46. <script >
  47.  
  48. $(document).ready(function() {
  49. $('#myForm').on('submit', function(e) {
  50. e.preventDefault();
  51. var btn = $(this).find("input[type=submit]:focus");
  52. var precio = btn.closest('td').prev('td').find('input').val();
  53. var cantidad = btn.closest('td').find('input').first().val();
  54. btn.closest('td').next('td').html("$" + (parseFloat(precio) * parseFloat(cantidad)))
  55. });
  56. });
  57.  
  58. </script>
  59.  
  60. </form>
  61.  
  62.  
  63.  
  64.  
  65.  
  66. <caption>Detalle de orden de compra</caption>
  67.  
  68.  
  69.  
  70. </body>
  71. </html>
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement