Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Confirmation Box
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Confirmation Box

 Post Reply Post Reply
Author
judo2000 View Drop Down
Groupie
Groupie
Avatar

Joined: 05 November 2002
Location: United States
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote judo2000 Quote  Post ReplyReply Direct Link To This Post Topic: Confirmation Box
    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



Edited by judo2000
If you are not willing to work hard to realize your dreams, why bother dreaming?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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>

 

Back to Top
judo2000 View Drop Down
Groupie
Groupie
Avatar

Joined: 05 November 2002
Location: United States
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote judo2000 Quote  Post ReplyReply Direct Link To This Post 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



Edited by judo2000
If you are not willing to work hard to realize your dreams, why bother dreaming?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.