Passing global variables 
Author Message
 Passing global variables

Hello all. I need a method of passing a global variable from JavaScript to
VBScript for insertion into a database. Any thoughts or ideas? Thanks very much
for any guidance on this.

--

keith.

Keith Parnell
SurfDesign Webs

http://www.*-*-*.com/
=============
FrontPage User Tips < http://www.*-*-*.com/ ;
FrontPage Web Hosting < http://www.*-*-*.com/ ;
FrontPage Community < http://www.*-*-*.com/ >



Tue, 24 Jul 2001 03:00:00 GMT  
 Passing global variables

Quote:

>Hello all. I need a method of passing a global variable from JavaScript to
>VBScript for insertion into a database. Any thoughts or ideas? Thanks very
much
>for any guidance on this.

You can only do this if JScript is your default language, and the variable
is declared inside an inline (<% %>) script block. If the default language
is VBScript, or if the variable is inside a <script> block, then you will
get errors (Type Mismatch) since the variable is undefined.

This has to do with the order of script execution. The following code shows
this happening - it generates a run-time error within the *JScript* code
saying that the *JScript* variabe is not defined. Note that you can't call
<script>-defined variables from within inline script *even if* they are in
the _same_ language.

Peter

--
Peter Torr, Developer / Webmaster, Vantage Systems Australia.


<%
var g_Var = "This Works";

function GetVar()
{
 return g_Var;

Quote:
}

%>

<script language="vbscript" runat="server">
Sub TestFunction()
 Response.Write "<h2>Via Function Call</h2><p>" + GetVar() + "</p>"
End Sub

Sub TestDirect()
 Response.Write "<h2>Direct</h2><p>" + g_Var + "</p>"
End Sub
</script>

<script language="javascript" runat="server">
var g_Var2 = "This will never be printed on the screen";

function GetVar2()
{
 return g_var2;

Quote:
}

</script>

<script language="vbscript" runat="server">
Sub FailFunction()
 Response.Write "<h2>Via Function Call</h2><p>" + GetVar2() + "</p>"
End Sub

Sub FailDirect()
 Response.Write "<h2>Direct</h2><p>" + g_Var2 + "</p>"
End Sub
</script>

<h1>Using in-line script (works)</h1>
<%
TestFunction();
TestDirect();
%>

<h1>Using script block (doesn't work)</h1>
<%
FailFunction();
FailDirect();
%>



Fri, 27 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Pass global variable from form to form

2. Passing Global Variables

3. Passing Global Variables

4. Passing global variables

5. Global Variable passed to Parameter

6. Passing a global variable between UserControl *.ocx's

7. Global Variables / Global Objects

8. Referencing Global Variable from a variable

9. passing javascript variable into asp variable using vbscript

10. Pass client script variable to server script variable

11. Passing Javascript Variables to VBscript (ASP) Variables

12. passing date variable in select statment of recordset variable

 

 
Powered by phpBB® Forum Software