Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Popup confirm not working.

Posted on 2012-12-29
4
Medium Priority
?
297 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:Aleks
  • 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:Aleks
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:
Aleks 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:Aleks
ID: 38771608
No solution was added ... closing this question.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

783 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