I have 2 simple asp pages here, where i want to get a server side variable from a client side vbscript. The following code works well and i am able to get the server side variable and display it in the client side message box. Notice that the client side script is inside the <body> tag.
***********************************************
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<% dim testvariable
testvariable = "Hello"
%>
<form name=form1 >
<input type=button name="button1" value="Click Me">
</form>
<P> </P>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=vbscript>
<!--
sub button1_onclick()
msgbox "<%=testvariable%>"
end sub
//-->
</SCRIPT>
</BODY>
</HTML>
********************************************************
Now in the following page the i am not able to get the value of the server side variable. In this case i move the client side vbscript in the <head>section on the page instead of the body
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=vbscript>
<!--
sub button1_onclick()
msgbox "<%=testvariable%>"
end sub
//-->
</SCRIPT>
</HEAD>
<BODY>
<% dim testvariable
testvariable = "Hello"
%>
<form name=form1 >
<input type=button name="button1" value="Click Me">
</form>
<P> </P>
</BODY>
</HTML>
********************************************************
What is the difference? why does it work when the script is in the body tag. also it does not work even if i put the client side vbscript above the server side code in the Body tag itself. Does it not always execute server side script first?
Any responses will be appreciated.
Thanks
***********************************************
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<% dim testvariable
testvariable = "Hello"
%>
<form name=form1 >
<input type=button name="button1" value="Click Me">
</form>
<P> </P>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=vbscript>
<!--
sub button1_onclick()
msgbox "<%=testvariable%>"
end sub
//-->
</SCRIPT>
</BODY>
</HTML>
********************************************************
Now in the following page the i am not able to get the value of the server side variable. In this case i move the client side vbscript in the <head>section on the page instead of the body
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=vbscript>
<!--
sub button1_onclick()
msgbox "<%=testvariable%>"
end sub
//-->
</SCRIPT>
</HEAD>
<BODY>
<% dim testvariable
testvariable = "Hello"
%>
<form name=form1 >
<input type=button name="button1" value="Click Me">
</form>
<P> </P>
</BODY>
</HTML>
********************************************************
What is the difference? why does it work when the script is in the body tag. also it does not work even if i put the client side vbscript above the server side code in the Body tag itself. Does it not always execute server side script first?
Any responses will be appreciated.
Thanks