Harakin, you didn’t post the codes but I know them from another question.
Edit your question by placing the codes for better understanding of other users of both the question and the answer.
Here’s the solution to your case.
In the script add these two lines
document.getElementById("vpedido").value = parseFloat(valorTotal).toFixed(2);
document.getElementById("total").value = parseFloat(valorTotal+5).toFixed(2);
HTML - included <input type="hidden" id="vpedido" name="vpedido" value="" />
<input type="hidden" id="total" name="total" value="" />
$(document).ready(function() {
$(".pizza-add-sub").append('<div class="plus qty-pizza">+</div><div class="mines qty-pizza">-</div>');
$(".qty-pizza").on("click", function() {
var $button = $(this);
var oldValue = $button.parent().find("input").val();
if ($button.text() == "+") {
var newVal = parseFloat(oldValue) + 1;
} else {
// Don't allow decrementing below zero
if (oldValue > 0) {
var newVal = parseFloat(oldValue) - 1;
} else {
newVal = 0;
}
}
$button.parent().find("input").val(newVal);
var valorTotal = 0;
var valoresMultiplicar = 0;
$(".qtdpedidos").each(function() {
valorTotal += parseFloat($(this).data("preco") * $(this).val());
})
$(".item span").each(function() {
valoresMultiplicar += parseFloat($(this).html());
})
if (valorTotal==0){
$("#tot").text("");
$("#resultado").text('');
}else{
$("#tot").text('R$'+(parseFloat(valorTotal+5).toFixed(2)));
$("#resultado").text('R$'+parseFloat(valorTotal).toFixed(2));
document.getElementById("vpedido").value = parseFloat(valorTotal).toFixed(2);
document.getElementById("total").value = parseFloat(valorTotal+5).toFixed(2);
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form method="post" action="PaginaDestino.php">
<div class="media-body">
<div class="quantity">
<div class="pizza-add-sub">
<input data-preco="10.00" type="text" id="qtdpedidos" class="qtdpedidos" value="0" />
</div>
</div>
<div class="item" class="pizza-price">
<span id="Span1" class="pizza">P. Unit R$10.00</span>
</div>
</div>
<input type="hidden" id="vpedido" name="vpedido" value="" />
<input type="hidden" id="total" name="total" value="" />
<input type="submit" value="Submeter" name="B1">
</form>
<div class="last-liner">
<p>Valor do Pedido: <span id="resultado" class="resultado"></span></p>
<p>Taxa de Entrega: <span id="txa" class="txa">5.00</span></p>
<p>Total: <span id="tot" class="tot"></span></p>
</div>
Page receiving the data
<?php
$vpedido = $_POST['vpedido'];
$total = $_POST['total'];
?>
<div class="last-liner">
<p>Valor do Pedido: <span id="resultado" class="resultado"><?php echo $vpedido;?></span></p>
<p>Taxa de Entrega: <span id="txa" class="txa">5.00</span></p>
<p>Total: <span id="tot" class="tot"><?php echo $total;?></span></p>
</div>
That’s not necessarily
PHP
. You need to learn the basics of the method (method attribute) attribute ofFORM
inHTML
. ThePHP
captures this data sent byFORM
in aarray
and then becomes easy to use or show. It is also possible to doPOST
withJavaScript
, but this already seems to me too advanced for you...– ShutUpMagda