Solved

Confirm Dialog Box

Posted on 2004-04-07
2
277 Views
Last Modified: 2008-02-01
I'm trying to add a confirm dialog box to my asp page.  I've never used this before and I've tried using the following but the asp code runs whether I click yes or no:

<script language="VBScript">
msg = "Yes or No?"
msgTitle = "Question"
If MsgBox(msg, vbYesNo, msgTitle) = vbYes Then
    'if yes was clicked
      <%varSQL = "DELETE FROM tips_TipDetails WHERE intTipID = " & request("ID")
      conn.Execute varSQL%>
      MsgBox "Yes!"    
Else
      MsgBox "No!"
End If
</script>

If I click yes, the yes box apears and the record is deleted.  If I click No, the No box appears and the record is also deleted.

I could be completely on the wrong track here so any ideas on how to do this sort of thing would be appreciated.

Thanks
Drizzt
0
Comment
Question by:Drizzt95
[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
2 Comments
 
LVL 12

Accepted Solution

by:
kingsfan76 earned 100 total points
ID: 10779739
the problem is that you are mixing the server side code in your client side script.

all server-side script (the codes inside <%...%>) are executed independent of your client-side script, so no matter what condition you set in your client-side script, the server-side script always run.

The way you should do it is use the confirm dialog box to submit the form with the ID, then when the form is submitted to another page (or itself) then delete the record with your server-side script

If MsgBox(msg, vbYesNo, msgTitle) = vbYes Then
    MsgBox "Yes!"
    document.FormName.submit   '<-- submit the form
Else
    MsgBox "No!"
End If



0
 
LVL 3

Author Comment

by:Drizzt95
ID: 10779853
Yep, that works fine.

Thanks for your quick help.
Drizzt
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FileUp - Classic ASP 5 27
Select case on click 3 31
Diminish Pop-up  in 3 seconds 7 79
JQuery Autocomplete Tag AJAX (Need nice script) 11 77
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

710 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