Solved

Popup confirm not working.

Posted on 2012-12-29
4
288 Views
Last Modified: 2013-01-13
I have a button in my form which will redirect the user to another page, but before this happens I added a 'pop-up confirm'.
If I use a regular image it works fine, but if I use this button the pop-up comes up and even though i select 'cancel' in the pop up then the user is re-directed, and they shouldn't.

What is wrong with this code ?

<input name="BtnArchive" type="button" class="bodytext" id="Btncancel2" onClick="GP_popupConfirmMsg('Please confirm you wish to archive this contact.\r\rNote that all of this contact\'s cases will also be archived automatically.');self.location='ArchiveContactandCases.asp?NewUserid=<%=(ContactDetails.Fields.Item("UserId").Value)%>';return document.MM_returnValue" value="    Archive Contact    ">
0
Comment
Question by:amucinobluedot
  • 3
4 Comments
 
LVL 13

Expert Comment

by:themrrobert
ID: 38729945
Because you are telling the code to change location to ArchiveContactandCases.asp every time.

You do this nClick="GP_popupConfirmMsg('Please confirm you wish to archive this contact.\r\rNote that all of this contact\'s cases will also be archived automatically.');self.location='ArchiveContactandCases.asp?NewUserid=<%=(ContactDetails.Fields.Item("UserId").Value)%>';return document.MM_returnValue

which is like this:

GP_popupConfirmMsg('Please confirm you wish to archive this contact.\r\rNote that all of this contact\'s cases will also be archived automatically.');
self.location='ArchiveContactandCases.asp?NewUserid=<%=(ContactDetails.Fields.Item("UserId").Value)%>';
return document.MM_returnValue

Open in new window

As you can see here, it doesn't matter what happens in the GP_popupConfirmMsg, you always send the webpage to the Archivecontact... page in the very next line.

From google, I think the function you are using is like this:

function GP_popupConfirmMsg(msg) {
    if ( confirm(msg) ) {
        window.location = 'my page blah.asp';
    }
}

Open in new window


It is in this function that you should put the destination... (and any other code that should happen based on the selection.
0
 

Author Comment

by:amucinobluedot
ID: 38730010
It uses a dreamweaver extension, i add the first one to confirm, then add the next one to redirect IF first one works.
Is there a way to stop on the first one if user clicks 'cancel' ?
0
 

Accepted Solution

by:
amucinobluedot earned 0 total points
ID: 38730042
In fact using a regular image and having both codes works fine:

<a href="SPDeleteAddInfo.asp?NewUserId=<%=(ContactDetails.Fields.Item("UserId").Value)%>&COMID=<%=(AddCommSection.Fields.Item("COMID").Value)%>" onClick="GP_popupConfirmMsg('Please confirm you wish to delete this \&quot;Additional Information\&quot; section. This cannot be undone.');return document.MM_returnValue"><img src="../../Images/Buttons/BtDelete.gif" width="84" height="20" border="0"></a>

Confirm, then redirect. It of course uses a simple a href.

Second code redirects even if confirm is cancelled, first one doesnt.

<input name="Btndelete" type="button" class="bodytext" id="Btndelete" onClick="self.location='SPDeleteAddInfo.asp?NewUserId=<%=(ContactDetails.Fields.Item("UserId").Value)%>&COMID=<%=(AddCommSection.Fields.Item("COMID").Value)%>'" value="    Delete    ">
0
 

Author Closing Comment

by:amucinobluedot
ID: 38771608
No solution was added ... closing this question.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

708 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

17 Experts available now in Live!

Get 1:1 Help Now