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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing javascript variable to vbscript

    newbie in javascript just wanna ask if it is possible to pass javascript variable to vbscript? if possible pls do give me an example.

    thanks in advance guys,
    paul

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    You may be able to pass values between JScript and vbScript as they can both run in Internet Explorer, the one browser that offers those two languages instead of javascript. Should just be a matter of making them global variables and using the same name in JScript as in vbScript. You can't exchange data between Javascript and vbScript though because Internet Explorer doesn't run Javascript and other browsers don't run vbScript.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>JS to VBScript</title>
    <script type="text/vbscript" language="vbscript">
    ' Declare a VB variable
    Dim intVariable_VB
    intVariable_VB = 13
    
    ' VB Function
    Function getVariable_VB(intAdd)
    	getVariable_VB = 7 + intAdd
    End Function
    </script>
    
    <script type="text/javascript" language="javascript">
    /* check if IE */
    if(typeof window.ActiveXObject != "undefined") {
    	/* The VBScript variable */
    	var intVariable = intVariable_VB;
    	alert(intVariable);
    	
    	/* The result of the VBScript function */
    	var getVariable = getVariable_VB(3);
    	alert(getVariable);
    }
    </script>
    </head>
    
    <body>
    </body>
    </html>
    Hope this helps

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper


  •  

    Posting Permissions

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