I am currently working on this project , which is required for the user to input financial values to calculate the total , I have been able to make an html form , and then php program to calculate and output the total.
Now the thing i want to know is how can i make the the div with id - total to refresh each time the refresh button for that function is clicked , without refreshing the whole page , so that if the user changes a number , the total shows always the correct value. that is , i want the div --> total to update upon click while other entered details are kept intact
Here is my code:
<form method="post" action="calc.php" autocomplete="on">
Data : <input type="date" name="data" data-date-inline-picker="false" data-date-open-on-focus="true" placeholder="la tua risposta" /><br />
Ricevuta(€) : <input type="number" name="ricevuta" placeholder="la tua risposta" step="any" /><br />
* : <input type="number" name="a" placeholder="la tua risposta" step="any" /><br />
BM(€) : <input type=number name="bm" placeholder="la tua risposta" step="any" /><br />
Ass/Bon(€) : <input type="number" name="ass_bon" placeholder="la tua risposta" step="any" /><br />
Cont(€) : <input type="number" name="cont" placeholder="la tua risposta" step="any" /><br />
<div id="total">
Total(€) :
<?php
$data = $_POST["data"];
$ricevuta = $_POST["ricevuta"];
$a = $_POST["a"];
$bm = $_POST["bm"];
$ass_bon = $_POST["ass_bon"];
$cont = $_POST["cont"];
$total=$_POST["total"];
$total = $_POST["bm"] + $_POST["ass_bon"] + $_POST["cont"];
echo $total;
?>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#total").load("calc.php");
});
});
</script>
<button>refresh</button>
<br>
Note : <textarea name="note" placeholder=" "></textarea><br />
<input type="submit" value="Invia" />
</form>