Solved

Popup confirm not working.

Posted on 2012-12-29
4
290 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

862 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

23 Experts available now in Live!

Get 1:1 Help Now