How to clear signup form on reload?

I am using this code on my website to allow visitors to sign up for the newsletter:

<style type="text/css">
form {padding-left: 100px;}
span.label,span.spacer,span.multiple span {width:120px;float:left;}
span.multiple {float:left;}
span.button {padding-left:120px;}
div.clear {clear:both;padding-top:5px;}
.button input {width: 188px; height: 50px;}
</style>

<!-- Form -->

<form action="http://bluelagoon.createsend.com/t/y/s/yhms/" method="post" id="subForm">

<div>
<span class="label"><label for="yhms-yhms">Email Address:</label></span>
<span><input type="text" name="cm-yhms-yhms" id="yhms-yhms" size="25" /></span>
</div>
<div>
<br />
<div>
  <span class="label"><label for="Country">Country:</label></span>
  <span><input type="text" name="cm-f-truua" id="Country" size="25" /></span>
</div>
</div>
<div><br />
<span class="button"><input type="submit" value="Subscribe" /></span>
</div>
</form>

It's a copy/paste from Campaign Monitor's Create a subscribe form feature (with minor CSS tweaks).

What I was wondering was how to clear the form on reload? That is when the user has gotten the confirmation that they signed up and then press the back button or 'Click here to return to the site' (like the confirmation states).

I know there must be something easy I can add to the form somehow, but I'm not good at PHP. Any help would be greatly appreciated.

rosastef, 6 years ago

I think I figured it out myself and decided to post the solution here in case somebody else got into the same dilemma.

I added this code to the header of my document:

<script>
function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}
</script>

Now my form clears on reload in Internet Explorer. I was only concerned with IE because my form will only be used on an in-store display that uses and old version of IE.

Please note: The code does not seem to work as intended in Firefox (have not checked other browsers).

Join 150,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098