I'm making a filter in PHP but I need javascript to fill the form after pushing submit button (for people to see what they entered in the form).
To do so, I did this:
<form method="post">
<div style="display:flex;margin-top:20px;">
<input name="surfMin" id="surfMin" type="text" style="height: 35px;width: calc(100%/3);" placeholder="min surface">
<input name="surfMax" id="surfMax" type="text" style="height: 35px;width: calc(100%/3);" placeholder="max surface">
<input name="prix" id="prix" type="text" style="height: 35px;width: calc(100%/3);" placeholder="price">
</div>
<div style="width:100%;margin-top:30px;text-align: center;">
<input id="button" style="width: 25%;height: 35px;background: #dc3545;color:white;" type="submit" name="search" />
</div></form>
if (isset($_POST['surfMin']))
print " <script>
document.getElementById('surfMin').value = '" . $_POST['surfMin'] . "'
</script>";
if (isset($_POST['surfMax']))
print " <script>
document.getElementById('surfMax').value = '" . $_POST['surfMax'] . "'
</script>";
if (isset($_POST['prix']))
print " <script>
document.getElementById('prix').value = '" . $_POST['prix'] . "'
</script>";
This code is working perfectly except if I try to fill again new values in the form. The last values stayed in. I want to delete all values if we click on any input to be capable of to refill it.
How can I to do so ?