0
Как создать калкулятор
3 Réponses
+ 6
Подойдет в JS?
0
<?
$a = $_POST['a'];
$b = $_POST['b'];
$radio = $_POST['operation'];
if ($_POST['button'])
{
if ($radio=='+'){$c = $a + $b; echo "Ҳосили ҷамъ=" . $c.'<br>';}
if ($radio=='-'){$d = $a - $b; echo "Ҳосили тарҳ=" . $d.'<br>';}
if ($radio=='*'){$e = $a *$b; echo "Ҳосили зарб=" . $e.'<br>';}
if ($radio=='/'){$f = $a / $b; echo "Ҳосили тақсим=" . $f;}
}
?>
<form method="POST" action="">
<input type="radio" name="operation" value='+'>+<br>
<input type="radio" name="operation" value='-'>-<br>
<input type="radio" name="operation" value='/'>/<br>
<input type="radio" name="operation" value='*'>*<br>
А=<input type="text" name="a" required><br><br>
В=<input type="text" name="b" required><br><br>
<input type="submit" name="button" value="Натиҷа">
</form>