Solved

Popup confirm not working.

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

615 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