-
Hi all,
I don't know whether I am a the right place or not, anyway, I am here now!
My question is how to assign the value of Script variable to ASP variable, well this question is best understood by an example:
* in 'Process.asp' I have the following:
.
.
Application("UserName") = ""
.
.
<script language=JavaScript>
.
.
var tmpUser
tmpUser = Application("UserName"); <<--- the problem here
.
.
</script>
The problem is that I can't assign the value of a Script variable to ASP variable (and vice versa by the way!).
Can anyone help ??
Thanks in advance,
Poor Wesam !!
-
What error(s) are you getting?
What exactly are you trying to do?
It looks like you are truing to assign a server-side variable to client-side script
Are you trying to write client side javascript?
Code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Application("UserName") = "Mark"
Response.Write "<script language=JavaScript>"
Response.Write "var tmpUser;"
Response.Write "tmpUser ='" & Application("UserName") & "';"
Response.Write "</script> "
%>
</BODY>
</HTML>
or server side?
Code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Application("UserName") = "Mark"
%>
<script language=JavaScript runat=server>
function XX(){
var tmpUser;
tmpUser = Application("UserName");
return tmpUser;
}
</script>
<%
Response.Write XX()
%>
</BODY>
</HTML>
Or none of these?
-
Ooh .. that's it, thank you for your help, I reviewed the code in your second example and I found that the problem was in the clause "<script language=JavaScript>" .. I did not specify "RunAt=Server" and that's why my code never worked.
Thanks a lot,
Happy Wesam !