First of all, a cordial greeting! I tell you my drawback: I have 2 lists of inventory type (one is the origin of the data and the other should print the values entered in the first to be sent by email) the thing is that the values such as VAT, without VAT, profit, carry some mathematical operations whose results should be printed in the Worksheet 2 as I introduce them in the < em> Worksheet 1 now, each worksheet has 70 rows of 9 fields each then in the Worksheet 1 I extract the current values of the same from the BD in an array and I show them in editable inputs in which the user edits their value and these are printed in the Worksheet 2 using the new function > OUTPUT of HTML5 *** (This so that the impressions of the values in the Sheet 2 are shown in real time) ...
The question is whether I can carry out mathematical operations on those values while I am passing them from Form 1 * to Form 2 . , instead of showing the value entered by the user in the Worksheet 1 , it should be shown is the result of the operation (Division, subtraction, multiplication) in the Worksheet 2 (in real time, it should be noted that there are 2 different forms in 2 spreadsheets that are displayed one over the other on the same page because I know how to do this when the input is of the same form and they are together, in addition to being purely HTML5 and in my case I need to use PHP) , I have searched in several parts and can not find anything, the effect that I intend to obtain is like that of the Excel formulas, it would be Great if you could help me, any other information you need can be requested. Annex relevant fragments of the code:
<?php
require ('php/conexion.php');
/* REALIZO CONSULTA PARA LA TABLA 1 Y LOS ALMACENO EN UN ARRAY */
$consulta ="SELECT * FROM 'planilla' ORDER BY 'planilla'.'cod' ASC LIMIT 70";
$result= mysql_query($consulta);
$a = 0;
while($row = mysql_fetch_array($result)) {
if ($a<=70)
{
$a++; /* ESTA VARIABLE LA HE CREADO PARA QUE CADA DATO EXTRAÍDO DE LA CONSULTA POSEA UN "ID" DIFERENTE (EJM: valor1, valor2, valor3...) */
?>
<tr>
<td><?php echo $row['cod'];?></td>
<td><?php echo $row['producto'];?></td>
<!-- EN ESTA LÍNEA APLICO LA FUNCIÓN DE HTML5 PARA ENVIAR LOS DATOS EN TIEMPO REAL A LA PLANILLA 2 -->
<td>
<form id="form_costo<?php echo $a?>" name="form_costo<?php echo $a?>" method="POST" oninput="<?php echo "re_costos" . $a?>.value=parseInt(<?php echo "costos" . $a?>.value)">
<input type="number" id="<?php echo "costos" . $a?>" name="<?php echo "costos" . $a?>" value="<?php echo $row['costo'];?>" class="form-control">
</form>
</td>
</tr>
</tbody>
<?php
}
}
?>
</table>
</div>
<!--- FIN de la TABLA 1 --->
Now I show you how they are captured in table 2, which is where I need the mathematical operations to be executed in real time. Or if there is a way to apply it to the results of the query to the DB directly to the results extracted by the array, it would also serve me, that is, it would be ruled out of "In real time", I explain: I get results through the array and to these I am applying the mathematical operations (If it is possible, of course) any of the 2 options can be of help. Thanks in advance
<!-- INICIO TABLA 2 --->
<?php
require ('php/conexion.php');
/* AQUI REALIZO OTRA CONSULTA SÓLO PARA EXTRAER EL "CÓDIGO" Y LOS "PRODUCTOS" Y MOSTRARLOS EN UN ARRAY EN LAS PRIMERAS 2 COLUMNAS */
$consulta2 ="SELECT * FROM 'planilla' ORDER BY 'planilla'.'cod' ASC LIMIT 70";
$result2 = mysql_query($consulta2);
$b = 0;
while($row = mysql_fetch_array($result2)) {
if ($b<=70)
{
$b++; /* AQUI HE CREADO UNA VARIABLE PARA LA MISMA FUNCIONALIDAD DE LOS "ID" EN LA ANTERIOR */
$codigo = $row['cod']; /* ALMACENO CODIGO EN UNA VARIABLE */
$produc = $row['producto']; /* ALMACENO CODIGO EN UNA VARIABLE */
echo "<TD>$codigo</TD>"; /* IMPRIMO CÓDIGO */
echo "<TD>$produc</TD>"; /* IMPRIMO PRODUCTO */
/* CON ESTA PORCIÓN DE CÓDIGO VOY IMPRIMIENDO LOS VALORES DE COSTO QUE EL USUARIO VAYA INTRODUCIENDO EN LA TABLA 1: <output form='form_costo$b' name='re_costos$b' for='costos$b'></output> */
/* EN LA SIGUIENTE LINEA PUEDEN VER COMO SE IMPRIMEN LOS VALORES DE COSTOS QUE SE VAN INTRODUCIENDO EN LA PLANILLA 1 Y ES DONDE NECESITO QUE EN LUGAR DE IMPRIMIR EL VALOR DIRECTAMENTE SE IMPRIMA EL RESULTADO DE LA OPERACION MATEMATICA */
echo "<TD><output form='form_costo$b' name='re_costos$b' for='costos$b'></output></TD>";
?>
</tbody>
<?php
}
}
?>
<!-- FIN DE TABLA 2 --->
The friend's response helped me to print the result of "No VAT", since I get the PVP value and divide it by 1.21 directly. Now in this case the question would be: How can I assign the values obtained from a previous operation to a variable to combine it with another operation? Example:
RRP - Result of "Without VAT"