Solved

Popup confirm not working.

Posted on 2012-12-29
4
294 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
[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
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

734 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