Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SIMPLE YES/NO ALERT - URGENT

Posted on 2003-12-10
4
Medium Priority
?
1,115 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
[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 33

Accepted Solution

by:
sajuks earned 2000 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

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

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