0
How to print the HTML form details on the same page after pressing the SUBMIT button?
let say there are following entry fields Name: Age: Gender : country : Email : and then submit button.
3 odpowiedzi
+ 4
You have to use JavaScript or PHP. only with html you cannot do this thing. I will show you with JavaScript, if you want in other language I will show that also.
With JavaScript like
<form onsubmit="myfunc()">
<input type="text" id="vh">
<input type="password" id="vh1" />
<input type="submit" value="submit" name="submit" />
</form>
<script>
var v= document.getElementById("vh").value;
var c= document.getElementById("vh1").value;
document.write("Name: "+v+"<br>Password: " + c);
<\script>
with PHP
use isset function like this
if(isset($_GET['vh']))
echo $_GET['vh'];
but it does not work on that page. Use $_POST method. Like
<form action="" method="post" >
<input type="text" name="vh">
<input type="password" name="vh1" />
<input type="submit" value="submit" name="submit" />
</form>
<?php
if(isset($_POST['vh'])){
$users1 = $_POST["vh"];
$id = $_POST["vh1"];
echo $users1;
}
?>
And do not use PHP example on playground for this. Try to do this on localhost
+ 1
yes aditya told it correctly to do it in client side.
submit.onclick=window.print();
just add this js to page.
this would print the whole form page.
there is option to print only form too
0
Thanks Aditya👍