Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing a variable from Server in client side code?

Status
Not open for further replies.

efrost2

Programmer
Jul 18, 2001
50
US
I have an asp page which populates a variable on the server side, how do I get access to this variable in client side script.

<HTML>
<HEAD>
<SCRIPT language=javascript>
Function GetValue()
{
//Can I access MyVar here???
}
</SCRIPT>

</HEAD>
<BODY>
<%
dim MyVar
'do my database stuff
MyVar=value returned from server
%>
</BODY>
</HTML>
 
<SCRIPT language=javascript>
Function GetValue()
{
   var x=&quot;<%=aspvariable%>&quot;;
}
</SCRIPT>
 
Sorry, I didn't read all the way down. I never saw your variable name but here it is.

<SCRIPT language=javascript>
Function GetValue()
{
&nbsp;&nbsp;&nbsp;var x=&quot;<%=MyVal%>&quot;;
}
</SCRIPT>
 
Side note: You may need to drop the quotation marks around the <%=MyVal%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top