PHP - calculos de precios

 
Vista:

calculos de precios

Publicado por alexis (1 intervención) el 27/01/2020 01:10:05
hola buenas tardes, espero alguien me pueda ayudar con mi problema.
lo que pasa es que en mi pagina web tengo un apartado de compras de piezas con una tabla dinamica extraida de la base de datos. Mi problema es que quiero hacer el calculo del precio de la pieza sin refrescar la pagina y mostrarlo dentro de la misma tabla.

Este es el codigo donde muestro los productos:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
  include 'conexion.php';
  include 'header.php';
  ?>
  <br><br>
<table style="width: 105%;margin-left:-20px">
  <tr>
<th><center><font color="white">Imagen</center></th>
    <th><center><font color="white">Pieza</center></th>
    <th><center><font color="white">Datasheet</center></th>
    <th><center><font color="white">Precio</center></th>
    <th><center><font color="white"></center></th>
    <th><center><font color="white">Comprar</center></th>
    <th><center><font color="white">Agregar al carrito</center></th>
  </tr>
   <?php
  $consu="SELECT * from productos where ref=9";
$resu=mysqli_query($enlace,$consu);
while($mostrar=mysqli_fetch_array($resu)){
  ?>
<tr>
<td>
  <a class="respbox" href="data:image/jpg;base64,<?php echo base64_encode($mostrar['imagen']);?>" targetWidth="1000" targetHeight="1000">
<img src="data:image/jpg;base64,<?php echo base64_encode($mostrar['imagen']);?>" width="80" height="80">
<span></span>
</a>
</td>
<form action="agregarcarrito1.php" method="post">
<td><textarea type="text" name="productot1"  readonly="readonly" class="sinborde" style="width:300px;text-align: center; background-color: transparent;"><?php echo $mostrar['nom_prod']?></textarea></td>
<td><a href="<?php echo $mostrar['pdf'] ?>" target="_blank"><img src="/necko/img/pdf.png."height="50"width="50"/></td>
<td><div class="form-group" style="width: 230px" >
            <select class="form-control" id="precio">
            <option ><?php echo $mostrar['relacion1']?><?php echo $mostrar['precio1']?></option>
            <option ><?php echo $mostrar['relacion2']?><?php echo $mostrar['precio2']?></option>
            <option ><?php echo $mostrar['relacion3']?><?php echo $mostrar['precio3']?></option>
            <option ><?php echo $mostrar['relacion4']?><?php echo $mostrar['precio4']?></option>
            <option ><?php echo $mostrar['relacion5']?><?php echo $mostrar['precio5']?></option>
            <option ><?php echo $mostrar['relacion6']?><?php echo $mostrar['precio6']?></option>
          </select>
        </div> </td>
        <td>
          <h5 style="margin-top:-5px;margin-left:-15px">+ IVA &nbsp;</h5>
        </td>
<td><div>
            <center><input class="form-control required" type="number" min="0" value="0" name="cantidadt1"Style="width:80px; margin-top:-15px"></center>
            <input type="hidden" value="<?php echo $mostrar['id']?>" name="id">
            <input type="hidden" value="<?php echo $mostrar['ref']?>" name="ref">
            <input type="hidden" value="botones.php" name="pag">
    </div></td>
         <td>
          <center><button type="submit" name="pilas" class="sinborde" style="width:130px; margin-top:-10px;background-color: transparent;">
          <img src="/necko/img\carritocom.png" style="margin-left:-5%; margin-top:-6"></button></center></form>
        </td>
     </tr>
     <?php }
  ?>
  </table>
  <script type="text/javascript" src="/necko/js/respbox.js"></script>
    <script>
      respbox.applyBySelector('.respbox');
      window.onresize = respbox.updateLayout;
    </script>
<?php include 'footer.php' ?>

adjunto esta la foto de como es la estructura de la tabla y donde se encuentra el circulo es donde quiero que se muestre el precio calculado en base a la cantidad de piezas que tengo

ejemplo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder