Good Morning, π
I'm creating a calculation simulator, where the user can choose a product and the amount of that product he wants and in the end know the total price.
Now, what i'm doing is creating a page with the form and a JQuery script to get the calculation .php file (save.php)
<!---------------------------------------------------------->
<script>
$(document).ready( function()
{
$("#form_ved").submit(function()
{
$.post("save.php", $('#form_ved').serialize(), function(data) {
alert(data_ved.total);
//$("div.total_metro").text(data_ved.total_metro);
},'json');
});
});
</script>
<!---------------------------------------------------------->
<form name="form" id="form_ved" method="post" action="" onSubmit="return false">
<input type="hidden" value="calc_ved" name="action">
<table>
<tr>
<td class="campo">PREΓO POR M.L.:</td>
<?php if ($quantidade < 11) $total_metro=0;?>
<td style="width:104px; border:1px solid #A5ACB2;" class="valor"><div class="total_metro_ved"><?php echo $total_metro ." β¬";?></td>
<!--<td style="width:100px; border:1px solid #A5ACB2;" class="valor"><?php echo $rede;?>REDE </td>
<td style="width:100px; border:1px solid #A5ACB2;" class="valor"><?php echo $montagem;?> MONT </td>
<td style="width:100px; border:1px solid #A5ACB2;" class="valor"><?php echo $transporte;?> TRANSP</td>
</tr>-->
<tr>
<td class="campo">VALOR TOTAL:</td>
<td style="width:104px; border:1px solid #A5ACB2;" class="valor"><div class="total_ved"><?php echo $total_metro ." β¬";?></td>
</tr>
</table>
save.php:
$total= $preco_total_postes + $preco_quant_rede +$suplementos + $preco_deslocamento + $valor_arame_estica +$valor_total_clip +$valor_total_escora +$valor_farpado+$valor_exec_sapatas;
$total_metro=$total/$quantidade;
$total=number_format ($total,2,',', '.');
$total_metro=number_format ($total_metro,2);
$data_ved = array();
$data_ved['total_ved'] = $total;
$data_ved['total_metro_ved'] = $total_metro;
print json_encode($data_ved);
Hope you can help me..
Thank You,
PF2G