Solved

SIMPLE YES/NO ALERT - URGENT

Posted on 2003-12-10
4
1,084 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now