Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with confirmation box when user clicks cancel

Status
Not open for further replies.

michellerobbins56

Programmer
Jan 10, 2006
89
GB
For some reason when I click Cancel to the confirmation box that appears the page tries to reload. However it just hangs and eventually times out with a Page Cannot Be Displayed error with
"HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services"

Here is some detail about the error:
Error Type:
"Active Server Pages, ASP 0113 (0x80004005)
Te maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools."




Please can anyone tell me how I can simply allow the user to go back to the page they were on (i.e <%=strPageName%>)? I have tried using
window.location = "<%=strPageName%>"
But this doesn't work.

Thank you very much for any help. Here is the code (the first part of the code (if the user clicks OK) simply checks a form if a checkbox has been ticked - this all works fine, it is just the part of the code at the end if the user clicks cancel that causes the page to hang:


/*******************************************************/
function isCheckedQuoteBasket(f)
{


/**********************************************************
first confirm if user wishes to continue and submit the form
**********************************************************/
var response;
response = confirm("Please click OK to confirm your action.")

if(response) /*if ok is clicked*/
{
for (i = 0; i < f.elements.length; i ++)
{
if (f.elements.type == "checkbox" && f.elements.checked)
{
somethingChecked = true;
}
}
if(somethingChecked == false)
{
alert("Please select at least one item from the list");
}
return somethingChecked;
}

else /*cancel clicked*/
{
//window.location = "<%=strPageName%>"

alert("Cancel clicked"); /*HOW CAN I EXIT WITHOUT EVERYTHING CRASHING!*/
}

}
 
Basically if the user clicks cancel to the confirmation box I want them to go back to where they were. Is there a way of doing this...such as to 'reverse' the action some how? I have tried removing the Else code altogether but the same problem still occurs.

Thank you very much for any help.
 
Maybe use...
Code:
return false;
... at the point you know that cancel was clicked?

Depends on how you have your form html tag set up. Do a view-source from your browser and check the <form> tag contents... and past it between [code][/code] tags. Specifically looking to use the onsubmit attribute to do what you need.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
As a quick followup... it may be more useful to understand at what point you are calling this function... and how you are calling it.

Things that would be handy are... the <form> tag contents... the markup showing the button you click/the way the function is called.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Thank you! "return false"; worked. Exactly what I was looking for. Thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top