Solved

Confirm Dialog Box

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Button to go back 3 28
Multiflying 2 Input Text On a Table 7 31
Diminish Pop-up  in 3 seconds 7 44
edit .asp files 5 29
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

792 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