Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Post Unanswered: ASP and VBScript

    Hello out there,

    I have a small question: How is it possible to get the value of a variable (or an object) from my ASP Source Code in my file into a VBScript Code in the same file.
    For a better explanaiteion, here is same sample source:

    <%
    myvar="Hello"
    %>

    /* then some html source */

    <script type="text/vbscript">
    <!--
    function myfunction()
    alert(myvar)
    end function
    ' -->
    </script>

    Now the function "myfunction" is executed, when the user clicks on a button.

    And here's my problem: whenever the script function is executed, the variable myvar doesn't contain the information I stored in it. I think it's a problem of global definition/etc.

    I really need this, because I'm programming a Database WebInterface under ASP and I would like to use such a function to delete a record out of a specific table. Unfortunately I'm not able to get the Server Object for the database Connection into my VBscript function - do that I cannot execute any sqlcommands in my vbscript function.

    I would be glad if someone could help me,
    thx,
    Martin.

  2. #2
    Join Date
    Sep 2003
    Posts
    60

    Re: ASP and VBScript

    Martin, your ASP code can generate VB script code like this...
    Code:
    <%
       myASPvar="Hello"
    %>
    
    /* then some html source */
    
    <script type="text/vbscript">
    <!--
       function myfunction() 
          Dim myVBSvar
    
          myVBSvar = "<%=myASPvar%>"
          alert(myVBSvar)
          end function
    ' -->
    </script>
    ...or better yet, you could skip all the variables if they aren't used elsewhere...
    Code:
        alert("<%Response.Write "Hello" %>")

Posting Permissions

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