K
K
kiril90112018-05-01 15:03:32
PHP
kiril9011, 2018-05-01 15:03:32

How to draw a conclusion without reloading the data?

How to make a calculator written in php without reloading the page? here is a sample code:

<?

$a = $_POST['a'];

$b = $_POST['b'];
$b6 = $_POST['b6'];



if ($_POST['button'])

{

$c = $a + $b + $b6; echo "сумма=" . $c.'<br>';
    mail("111", "Тема", "$c");
    



}

?>
<html>
    <head>
        <meta charset=utf-8>
        
        </head>
        <body>
             <form method="POST" action="">

    
     <input type="text" name="a" required><br>

               <input type="text" name="b" required><br>
               <input type="checkbox" name=b6 value="2000"><br>

<input type="submit" name="button" value="Отправить">

</form>
            </body>
    </html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Romashkan, 2018-05-01
@EvgeniiR

Send a POST request to the server via AJAX and display a response to the user with javascript.
Or rewrite the calculator completely in JS. I had an assignment like this in college.
Here is the solution on codepen
https://codepen.io/evgrom/pen/OQrxYo
There are 4 operations. If you leave only addition, there will be 8 lines of js code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question