Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: vbScript + asp

  1. #1
    Regular Coder
    Join Date
    Mar 2003
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation vbScript + asp

    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:
    Code:
    <!--#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)
    	objRS.Close()
    	Set objRS = Nothing
    	
    	
    	MsgBox ("List Deleted!"), vbOKOnly)	
    	
    	response.redirect "viewLists.asp"
    	
    Else
    
    response.redirect "viewLists.asp"
    
    End If
    	
    	%>

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Location
    Brasília, Brazil
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is no MsgBox in Asp.

  • #3
    Regular Coder
    Join Date
    Mar 2003
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it possible to get it to work the wy the code needs to function?

    What is an effecient option?

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Location
    Brasília, Brazil
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use Response.Write() to print and the html tag <input> to get values from the user.

  • #5
    Regular Coder
    Join Date
    Mar 2003
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts
    a little lost, something like this:

    Code:
    <!--#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("objRS.Close()")
    .write("Set objRS = Nothing")
    
    .write("MsgBox ('List Deleted!'), vbOKOnly)")	
    
    .write("response.redirect 'viewLists.asp'")
    	
    .write("Else")
    
    .write("response.redirect 'viewLists.asp'")
    
    .write("End If")
    
    End With
    
    </script>

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •