Solved

Confirm Dialog Box

Posted on 2004-04-07
2
278 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

630 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