Solved

SIMPLE YES/NO ALERT - URGENT

Posted on 2003-12-10
4
1,095 Views
Last Modified: 2006-11-17
HI Experts,

Need a really quick answer to the following:

I need an alert box to pop up when a form is submitted with "are you sure you want to do this?" as the message and a choice of "yes" or "no" to be presented in the form of 2 buttons. If "yes" is clicked then the form is submitted, if "no" is clicked then the form is not submitted.


Thanks,



PJORDANNA

0
Comment
Question by:pjordanna
4 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 500 total points
ID: 9911648
<HEAD>



<SCRIPT LANGUAGE="JavaScript">
function getInfo() {
doyou = confirm("Do you want to continue? (OK = Yes   Cancel = No)");

if (doyou == true)
{

return true
}
else
{

return false
}
}
</script>
<BODY>

<form method="POST"  onSubmit ="return getInfo()">
<input type="text">
  <input type="submit" value="Submit" name="B1">
  <input type="reset" value="Reset" name="B2"></p>
</form>



</BODY>
0
 
LVL 7

Expert Comment

by:gam3r_3xtr3m3
ID: 9911680
try:

<form onSubmit="return confirm('Are you sure you want to do this?')">
<input type="submit" />
</form>
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9911866
or this,
this will call a form validation routine called validateForm() and if the data is valid will then prompt the user to confirm
<script>
function validateForm(objForm){
// data validation goes here
return true;
}

</script>
<form name="myForm" action="" method="" onSubmit="if(validateForm(this)){ return confirm('Are you sure you want to do this?\nClick Ok to continue or Cancel to stop.')} else { return false}">

<input type="submit" value="Submit">
</form>
0
 

Author Comment

by:pjordanna
ID: 9912113
OK that's got it.



PJORDANNA
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reactjs with .NET 3 70
links not working 2 25
Any Way to rotate banner ads from Commission Junction? 2 36
Link Anchor Not working 9 43
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 the basics of jQuery including how to code hide show and toggles. 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…

679 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