Solved

Confirm Dialog Box

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Visual Project Bridge error 5 56
Select distinct 25 60
Need help editing script 3 52
SQL to update characters in table column 6 29
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now