ilikephp Posted June 21, 2010 Share Posted June 21, 2010 Hi, I have a php form; When the user clicks on the submit button the form will be submitted, BUT if he press the back button, all the info in the field will be redisplayed :S How can they be cleared? Thank you, Link to comment https://forums.phpfreaks.com/topic/205466-clear-form-on-submit/ Share on other sites More sharing options...
robert_gsfame Posted June 23, 2010 Share Posted June 23, 2010 have u tried onunload <head> function clearform() { document.getElementById("textfield1").value=""; } </head> <body onunload=clearform()> <form name="form1" method="post" action="form2.php"> <input type="text" id="textfield1" name="textfield1"> <input type="submit" value="submit"> </form> </body> not yet tested but Link to comment https://forums.phpfreaks.com/topic/205466-clear-form-on-submit/#findComment-1076067 Share on other sites More sharing options...
haku Posted June 23, 2010 Share Posted June 23, 2010 There's no such thing as a PHP form. Forms are HTML. But ignoring that, something like this should work (you will have to play with it a bit): <form id="my_form" action="/" method="post"> <input type="text" id="my_field" name="something" /> </form> document.getElementById("my_from").onSubmit = function() { document.getElementById("my_field").value(""); } Link to comment https://forums.phpfreaks.com/topic/205466-clear-form-on-submit/#findComment-1076099 Share on other sites More sharing options...
ilikephp Posted June 24, 2010 Author Share Posted June 24, 2010 thx for your help Guys! I used this script and it works fine: onload=document.forms["form1"].reset(); Link to comment https://forums.phpfreaks.com/topic/205466-clear-form-on-submit/#findComment-1076608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.