Solved

Why Stack Overflow with Confirm Box

Posted on 2003-11-24
6
245 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
[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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

728 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