?
Solved

Javascript PopUp message on a form submit

Posted on 2007-12-03
4
Medium Priority
?
1,638 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 600 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 600 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

719 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