Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Confirm Dialog Box

Posted on 2004-04-07
2
Medium Priority
?
280 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 400 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

730 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