Print Page | Close Window

Confirmation Box

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1416
Printed Date: 29 March 2026 at 10:25am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Confirmation Box
Posted By: judo2000
Subject: Confirmation Box
Date Posted: 27 March 2003 at 3:42pm

Hi, I have a form that lets admins delete users from an amployees database.  That works fine, but I want to have a msgbox pop up and ask "Are you sure you want to delete Username"  with a yes and no choice.  My code is as follows:

<%
         
         'Loop through the recordset
         DO WHILE NOT rsSchedules.EOF
       
          response.Write("<tr bgcolor='#FFFFFF'>")
          response.Write("<td class='bodyTxt' valign='top'>")
          response.Write("<a href=""delete_employ.asp?ID=" & rsSchedules("empID") & """>")
          response.Write("Delete")
          response.Write("</a>")
          response.Write("</td>")
          response.Write("<td class='bodyTxt'>")
          response.Write(rsSchedules("empName"))
          response.Write("</td>")
          response.Write("<td class='bodyTxt'>")
          response.Write(rsSchedules("empPhone"))
          response.Write("</td>")
          response.Write("<td class='bodyTxt'>")
          response.Write(rsSchedules("empEmail"))
          response.Write("</td>")
          response.Write("<td class='bodyTxt'>")
          response.Write(rsSchedules("username"))
          response.Write("</td>")
          response.Write("</tr>")
          rsSchedules.MoveNext
         Loop
%>

I tried an onclick function and it worked but it either deleted the user no wheather I click yes or no or id didn't work at all.

Any help would be greatly appreciated



-------------
If you are not willing to work hard to realize your dreams, why bother dreaming?



Replies:
Posted By: michael
Date Posted: 27 March 2003 at 5:47pm

You can do this in VBScript.
<script language="VBScript">
myPrompt = MsgBox("Are you sure you want to delete?",3,"Important Question")
</script>
Variable myPrompt will contain 6 for yes, 7 for no an 2 for cancel.
Unfortunately, javascript does not provide a configurable alert box.
You could alternatively use a html popup like the following which I found somewhere. Just need to edit it to your taste:
<html>
<head>
<title>Confirm-box</title>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
<!--
var winConfirm = null;
function showConfirm()
{
 var windowWidth = 250;
 var windowHeight = 100;
 var locX = ( screen.width - windowWidth ) / 2;
 var locY = ( screen.height - windowHeight ) / 2;
 var windowFeatures = "width=" + windowWidth + ",height=" + windowHeight +
",screenX=" + locX + ",screenY=" + locY + ",left=" + locX + ",top=" + locY;
 if ( ( winConfirm != null ) && !winConfirm.closed )
 {
  winConfirm.close();
 }
 winConfirm = open( "", "winConfirm", windowFeatures );
 var theHTML = '<HEAD><TITLE>Please choose...</TITLE></HEAD>'
     + '<BODY BGCOLOR="#FFFFFF">'
     + '<CENTER><B>'
     + 'Click on YES, NO or CANCEL'
     + '</B><FORM NAME="buttonForm">'
     + '<INPUT TYPE="button" VALUE=" YES  "'
     + ' ONCLICK="opener.buttonClicked(0);self.close();">'
     + '&nbsp;'
     + '<INPUT TYPE="button" VALUE="  NO  "'
     + ' ONCLICK="opener.buttonClicked(1);self.close();">'
     + '&nbsp;'
     + '<INPUT TYPE="button" VALUE="CANCEL"'
     + ' ONCLICK="opener.buttonClicked(2);self.close();">'
     + '</FORM></BODY>';
 winConfirm.document.writeln( theHTML );
}
function buttonClicked( buttonChoice )
{
 switch( buttonChoice )
 {
  case 0:
   document.myForm.showResult.value = "YES";
   break;
  case 1:
   document.myForm.showResult.value = "NO";
   break;
  case 2:
   document.myForm.showResult.value = "CANCEL";
   break;
  default:
   document.myForm.showResult.value = "(void)";
 }
}
//-->
</SCRIPT>
<FORM NAME="myForm">
<INPUT TYPE="button" VALUE="Click here to see the confirm window"
ONCLICK="showConfirm();">
<BR><BR><B>The last button clicked was:</B>
<BR><INPUT NAME="showResult" TYPE="text" SIZE="10" VALUE="(void)"
ONFOCUS="blur();">
</FORM>
</body>
</html>

 



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: judo2000
Date Posted: 27 March 2003 at 5:49pm

I added the following script to the head of the page:

<script language="VBScript">
 Sub confirm_delete()
 
 myPrompt = MsgBox("Are you sure you want to delete?",3,"Important Question")
 if myPrompt = 7 THEN
 return false
 END if
 END Sub
</script>

deleteEmploy.asp is the current page.  I want it just do nothing if the uses presses no.  It does ask but it deletes the enter no matter what I chose but when I chose no it gives an error about the return statement.

I changed the line with the link to look like this:

response.Write("<a href=""delete_employ.asp?ID=" & rsSchedules("empID") & """ onClick=""return confirm_delete()"">")

Again, any help would be greatly appreciated.

Thanks,  Scott



-------------
If you are not willing to work hard to realize your dreams, why bother dreaming?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net