Answer the question
In order to leave comments, you need to log in
How to completely clear the form after "submit"?
Hello, I'm just learning all this, tell me how to clear all inputs after it has already counted them ( link - twoboxes-niflungar.c9.io ). The "clear" button itself works until the event itself.
actual code.
<?php
$val1 = $_POST['val1'];
$val2 = $_POST['val2'];
$val = $val1 + $val2;
?>
<!doctype html>
<html lanr="ru">
<head>
<title>2 Boxes | Tasks</title>
<meta charset="UTF-8">
<link href="css/style.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="images/favicon.png" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<!--Header-->
<?php
include ("header.php");
?>
<!--Задача №1-->
<?php
include ("summ.php");
?>
<script>
function myFunction() {
document.getElementById("summid").reset();
}
</script>
</body>
</html>
<code> PHP
<div class="box">
<p>№1 - SUMM</p>
<h2>Вычислить сумму двух box'ов</h2>
<p>-------------------------------------------------------</p>
<p>SMALL BOX</p>
<form id="summid" method="POST">
Введите цену за коробку №1<br><br>
<input class="one" type="number" value="<?=$val1?>" name="val1"> <br><br>
<p>BIG BOX</p>
Введите цену за коробку №2<br><br>
<input class="two" type="number" value="<?=$val2?>" name="val2"> <br><br><br>
<p>-------------------------------------------------------</p>
<input class="three" type="text" value="<?php if(isset($_POST['submit']))echo $val?>">
<input type="submit" name="submit" value="Посчитать сумму!"><br>
<p>-------------------------------------------------------</p>
<input type="button" value="Очистить форму!" onclick="myFunction()">
<p>-------------------------------------------------------</p>
</form>
</div>
</code>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question