View Full Version : vbScript + asp

04-16-2006, 08:34 AM
can someone plesae explain to me why this code in an asp page doesn't work correctly, this all the code that is in the asp page:

<!--#include file="includes\global.inc"-->
<!--#include file="includes\db.inc"-->
Dim MyVar

MyVar = MsgBox ("Are you sure you want to delete List?", vbOKCancel, "MsgBox Example")

If MyVar = 1 Then 'user pressed yes

strSql = "Update recruitmentLists Set DelGrp = 1 AND usey='no' Where groupID =" &Request.QueryString("grp")
Set objRS = gobjConn.Execute(strSql)
Set objRS = Nothing

MsgBox ("List Deleted!"), vbOKOnly)

response.redirect "viewLists.asp"


response.redirect "viewLists.asp"

End If


04-16-2006, 11:10 AM
There is no MsgBox in Asp.

04-16-2006, 09:30 PM
Is it possible to get it to work the wy the code needs to function?

What is an effecient option?

04-16-2006, 09:45 PM
Use Response.Write() to print and the html tag <input> to get values from the user.

04-16-2006, 10:32 PM
a little lost, something like this:

<!--#include file='includes\global.inc'--><!--#include file='includes\db.inc'-->
<script type="text/vbscript">
Dim MyVar
MsgBox ("Are you sure you want to delete List?", vbOKCancel, 'MsgBox Example')

With Response

.write("MyVar = MsgBox ('Are you sure you want to delete List?', vbOKCancel, 'MsgBox Example')")

.write("If MyVar = 1 Then") 'user pressed yes

.write("strSql = 'Update tbl93488 Set DelGrp = 1 AND usey='no' Where groupID =' &Request.QueryString('grp')")

.write("Set objRS = gobjConn.Execute(strSql)")

.write("Set objRS = Nothing")

.write("MsgBox ('List Deleted!'), vbOKOnly)")

.write("response.redirect 'viewLists.asp'")


.write("response.redirect 'viewLists.asp'")

.write("End If")

End With


04-17-2006, 07:16 PM
No, not at all.

ASP cannot directly interact with the user with things like message boxes. That's why it is a called a server-side language, it does its job before the data gets to the user.

What you need to do is have a form on the HTML page and ask the user. For example the yes button is a submit button for the form that sends them to the page to delete the list.

If you just can't live without having a message box you could probably get it to work with a combo of ASP and javascript but then the user needs to have javascript enabled for it to work.