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.

27th Nov 2016, 7:17 AM
Abhishek Kumar
Abhishek Kumar - avatar
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
27th Nov 2016, 2:39 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 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
27th Nov 2016, 9:03 AM
Sandeep Chatterjee
0
Thanks Aditya👍
27th Nov 2016, 7:32 AM
Abhishek Kumar
Abhishek Kumar - avatar