Solved

Javascript PopUp message on a form submit

Posted on 2007-12-03
4
1,637 Views
Last Modified: 2012-06-27
I have a form on a php page, and all i simply want is when a user clicks "submit" it brings up  a PopUp message / error.
I have gone through the site and for some reason have not found a simple solution.
So basically, when a user clicks the submit button, I want it to display a popup with a message and two buttons like ...
Are you sure you want to continue?
if "Yes" .... go to this page
if "No" .... close the popup and return to the same page

Thanks!
0
Comment
Question by:Dustballs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 150 total points
ID: 20397719
<form id="form1" onsubmit="return confirm('Are you sure you want to continue?');" action="<url>">
0
 
LVL 31

Assisted Solution

by:Frosty555
Frosty555 earned 150 total points
ID: 20397885
Hm does it work to put it in the onsubmit of the form? The way I've always done it is in the input button's onclick:

<input onclick="return confirm('Click OK to submit.');" type="submit" name="Submit" value="Submit">

But perhaps sinoj's solution works not only when you click the button, but also when something programatically submits the form or the user hits enter while inside the last textbox of the form. So try his first.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20397961
@Frosty555

Sinoj's suggestion of doing it in the form tag with the onsubmit event will work.  The "thoughts" you shared in your comment on its benefits are correct.  I recommend doing it in the onsubmit event in the form tag although there is nothing wrong with the way you suggested it.

I hope this helps. :)  Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:Dustballs
ID: 20398043
I've tried both ways and I think they work the exact same, I don't notice any difference. Both of them will work if the user hits return after entering data in any textbox in the form.
It's a toss of a coin really ;-) so i'll split the points, cheers!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question