Solved

Why Stack Overflow with Confirm Box

Posted on 2003-11-24
6
237 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
ID: 9814241
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
ID: 9814244
try changing the your function name to something else other than confirm(), such as
function submitConfirm()
{......}
0
 
LVL 12

Expert Comment

by:kingsfan76
ID: 9814251
almost posted at exact same time   :-)
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9816300
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
ID: 10383653
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

773 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