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, Quote Link to comment 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 Quote Link to comment 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(""); } Quote Link to comment 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(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.