1
would like to know if it is possible to run a real time calculation with jquery inside a php foreach and how? this is my code:
<?php
$Read = new Read;
$Read->ExeRead("c100web", "WHERE codclient = :client", "client={$Clie}");
if (!$Read->getResult()):
VARErro("Não á registros na lista, cadastre os produtos!", INFOR);
else:
foreach ($Read->getResult() as $Pedidos):
extract($Pedidos);
$Style = "";
$ReadProd = new Read;
$ReadProd->ExeRead("c007prod", "WHERE codigo = :cod", "cod={$codpro}");
if ($ReadProd->getResult()):
$Nome = $ReadProd->getResult()[0]['descricao'];
$PrecoUni = $ReadProd->getResult()[0]['preco_venda'];
endif;
?>
<tr>
<td><?= $Nome; ?></td>
<td><input disabled="" type="text" name="vlruni" id="vlruni" value="<?= $PrecoUni; ?>"/></td>
<td><input type="number" name="qnt[]" id="qnt" value="<?= $qntpro; ?>"/></td>
<td><input disabled="" type="text" name="vlrtl" id="vlrtl"/></td>
</tr>
<tr><td colspan="4" style="padding: 4px; background-color: #ccc;"></td></tr>
<?php
endforeach;
?>
<tr>
<td colspan="3">Valor total do pedido:</td>
<td><input disabled="" type="text" name="vlrlist" id="vlrlist"/></td>
</tr>
<?php
endif;
?>
is basically like this: vlruni * qnt = vlrtl and vlrtl + vlrtl + vlrtl.... = vlrlist, is it possible?... thank you!
HTML:
<tr>
<td>ACUCAR MASCAVO FAVINHO 500G</td>
<td><input disabled="" type="text" name="vlruni" id="vlruni" value="4.6"/></td>
<td><input type="number" name="qnt[]" id="qnt" value="12"/></td>
<td><input disabled="" type="text" name="vlrtl" id="vlrtl"/></td>
</tr>
<tr><td colspan="4" style="padding: 4px; background-color: #ccc;"></td></tr>
<tr>
<td>ACUCAR MASCAVO FAVINHO 1K</td>
<td><input disabled="" type="text" name="vlruni" id="vlruni" value="7.7"/></td>
<td><input type="number" name="qnt[]" id="qnt" value="10"/></td>
<td><input disabled="" type="text" name="vlrtl" id="vlrtl"/></td>
</tr>
<tr><td colspan="4" style="padding: 4px; background-color: #ccc;"></td></tr>
<tr>
<td>AMENDOIM AMENDUPÃ C/ CASCA 280G</td>
<td><input disabled="" type="text" name="vlruni" id="vlruni" value="2.7"/></td>
<td><input type="number" name="qnt[]" id="qnt" value="5"/></td>
<td><input disabled="" type="text" name="vlrtl" id="vlrtl"/></td>
</tr>
<tr><td colspan="4" style="padding: 4px; background-color: #ccc;"></td></tr>
What do you mean by real-time calculation? It has how to best describe?
– Woss
i type a new quantity in the qnt field and at the end of typing the multiplication is performed at the exact moment showing in the vlrtl field, and the sum of vlrtl fields is performed showing in the vlrlist field, it can be given a enter or not, if possible without the enter!
– JASL
I believe that the solution is easier only with Javascript. What is the HTML generated by PHP in this code?
– Woss
Jefferson, can exemplify this code in jsfiddle only with html generated in PHP?
– Diego Andrade
edited the question by inserting html!
– JASL