On Submit show Alert Box

I'm trying to figure out how when I hit the submit button I can have a box pop up that says

"Thanks for giving your opinion"

I tried the below code, but not working.

<form action="submitsurvey.php" onsubmit="alert('Thanks for giving your opinion');" enctype="multipart/form-data" method="post">
<li>
									<div class="radio">
										<input name="option" type="radio" class="off" value="'.$row3['id'].'"/>
										<a class="custom"></a>
									</div>	
									<div class="text">
										<label for="option" style="word-wrap:break-word;width:300px;">'.$row3['answer'].'</label>
									</div>	
								</li>
<input type="submit" class="btn blue" value="SUBMIT">
</form>

Open in new window

LVL 12
Nathan RileyFounderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
<form action="submitsurvey.php" enctype="multipart/form-data" method="post">
<input type="submit" class="btn blue" value="SUBMIT" onClick="alert('Thanks for giving your opinion');">
</form>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smeghammerCommented:
If you want full control over the submission, change the button type from SUBMIT to BUTTON, and add an onclick hander that calls a function:

<script>
function submitForm()
{
  //perhaps some client validation here
  document.forms["yourform"].submit();
  alert("Thanks for submitting.")
}
</script>
<input type="button" onclick="submitForm();" name="go" value="Go" />

Open in new window

In reality, you probably want to do validation and checking for successful form submission on the server, as a 'thank you' message should only be presented if the form was actually submitted correctly.
0
jjkkj jknykykCommented:
jk5tj55
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.