Jump to content

Clear a form on page refresh?


MildewMan1

Recommended Posts

I was wondering if there was a way to empty all check boxes that have been selected if the user refreshes the page. As of now, you can select some, refresh and they will still be checked.Edit:I got it to refresh in IE, but firefox still keeps checked values

Link to comment
Share on other sites

You could use JavaScript that resets the form on load, think you would do something like this

document.getElementById('myForm').reset();

Link to comment
Share on other sites

you could always do like this:

<html><head><title>myPage</title><script language="JavaScript" type="text/javascript">function resetform(){document.getElementById('myForm').reset();}</script></head><body onload="resetform()"><form id="myForm">   ....</form></body></html>

This way, when the body will reload, the form will reset

Link to comment
Share on other sites

I'll try this out and let you know if it works. Thanks for the responses.Edit: Nothing I have tried will work with FireFox =/

Link to comment
Share on other sites

you could always do like this:
<html><head><title>myPage</title><script language="JavaScript" type="text/javascript">function resetform(){document.getElementById('myForm').reset();}</script></head><body onload="resetform()"><form id="myForm">   ....</form></body></html>

This way, when the body will reload, the form will reset

Just wanted to thank you for this code. Had to tweak it a bit, but finally got it to work. Changed the "getElementById('myForm')" part just to the name of my form and it worked perfectly. This is what I used:
<script language="JavaScript" type="text/javascript">function UncheckAll(){document.NameOfMyForm.reset();}</script>

and then

<body onload="UncheckAll();">

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...