Thank you for the form notification

I have a very simple form http://www.happyholidaylites.com/contact.html and it works great. When you submit the form, the user is entered into index.html without a message that the form has been submitted. I'm looking to trigger an alert that says "Your form has been submitted" using the x button. My code looks like this:

      <form method="post" id="myForm" action="dynaform.php">

      <input type='hidden' name='rec_mailto' value='JBIRD1111@gmail.com'>
      <input type='hidden' name='rec_subject' value='New Contact Form'>
      <input type='hidden' name='rec_thanks' value='index.html'>

      

so on, etc ...

The last line is what tells the form what to do after clicking the submit button, but I don't want it to point the browser to the index, rather I want a javascript popup with a successful message. Any ideas?

+2


source to share


4 answers


Why not a simple onSubmit?



<form method="post" id="myForm" action="dynaform.php" onSubmit="alert('Thank you for your feedback.');" >

      

+6


source


To be honest, you are better off redirecting to another page to avoid the user re-submitting the page on refresh. Take a look at Publish / Redirect / Get Template .



Pop-ups can be extremely annoying on websites. You should create a page named "thank-you.html" where you can redirect the user to a successful view that has access to site navigation options or even just redirects back to the form page after a few seconds.

+4


source


Instead of redirecting to index.html, redirecting to thanks.html; your users will thank you because everyone hates pop-ups!

+2


source


It looks like your PHP script is handling the form submission by processing the input and redirecting the browser to the value in the field rec_thanks

.

You can add something like onsubmit="YourJavaScriptFunction()"

to the form tag to add client side behavior before the actual form submission. Within this function, you can check, use alert('Thank You!')

, etc.

0


source







All Articles