Solved

Why Stack Overflow with Confirm Box

Posted on 2003-11-24
6
231 Views
Last Modified: 2012-05-04
I got stack overflow error when I implement a confirm box.  I don't know how to fix it.  Here is my code:

function confirm() {
  if(confirm('Are you sure to continue?')){
    document.forms[0].submit();
  }
  else{
    return false;
  }
}

<form name="form1" method="Post" action="create_inspection.jsp" onsubmit="return validate()">

<input type="Button" name="Submit" value="Enter Inspection" onClick="confirm()">
</form>

This form and javascript is in jsp create_inspection.jsp.  If user confirm the action, the request will be sent to the same page for database insert; otherwise, user stay with the page without submitting the form.

If I get rid of the confirm, everything is good. But if I add the confirm box, I got the stack overflow error.

0
Comment
Question by:qding
  • 2
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
NetGroove earned 50 total points
Comment Utility
You did overwritten the confirm() method with your function.
Cahnge it to this:

function doConfirm() {
  if(confirm('Are you sure to continue?')){
   document.forms[0].submit();
 }
 else{
   return false;
 }
}

<form name="form1" method="Post" action="create_inspection.jsp" onsubmit="return validate()">

<input type="Button" name="Submit" value="Enter Inspection" onClick="doConfirm()">
</form>


0
 
LVL 12

Expert Comment

by:kingsfan76
Comment Utility
try changing the your function name to something else other than confirm(), such as
function submitConfirm()
{......}
0
 
LVL 12

Expert Comment

by:kingsfan76
Comment Utility
almost posted at exact same time   :-)
0
 
LVL 10

Expert Comment

by:NetGroove
Comment Utility
Hello qding,

do you confirm that upper comments solved your problem?
Or do you have also work overflow :)
0
 
LVL 16

Expert Comment

by:jaysolomon
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: NetGroove {http:#9814241}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now