C
Craig L
This is a solution followup to a request for help posted on 11/04/03 at
12:51pm titled "Using ASP Variables". Here is how you can make ASP variables
available for use in Javascript code. I hope you find this info as valuable
as I did. Thanks to everyone who helped me get to this solution with their
wonderful ideas.
1) Create session objects for the variables (this example provides strings,
but they could come out of a database):
<!-- Get data for Session Objects -->
<%
session("Firstname")="Mary"
session("Lastname")="Thomas"
%>
2) Create string values:
<!-- Set string values -->
<%
sFirstname=session("Firstname")
sLastname=session("Lastname")
%>
3) Use response.write to create the Javascript code:
<!-- Create Javascript variables -->
<%
response.write "<SCRIPT Language=" & chr(34) & "JavaScript" & chr(34) & ">"
response.write "var strFirstname=" & chr(34) & sFirstname & chr(34) &";"
response.write "var strLastname=" & chr(34) & sLastname & chr(34) &";"
response.write "</SCRIPT>"
%>
4) Now, strFirstname and strLastname values are avail for us in other
Javascript code.
Since I have the ASP to JS issue solved, I will work on the JS to ASP issue
soon. Thanks.
Craig
(e-mail address removed) (remove SPAM before emailing.)
12:51pm titled "Using ASP Variables". Here is how you can make ASP variables
available for use in Javascript code. I hope you find this info as valuable
as I did. Thanks to everyone who helped me get to this solution with their
wonderful ideas.
1) Create session objects for the variables (this example provides strings,
but they could come out of a database):
<!-- Get data for Session Objects -->
<%
session("Firstname")="Mary"
session("Lastname")="Thomas"
%>
2) Create string values:
<!-- Set string values -->
<%
sFirstname=session("Firstname")
sLastname=session("Lastname")
%>
3) Use response.write to create the Javascript code:
<!-- Create Javascript variables -->
<%
response.write "<SCRIPT Language=" & chr(34) & "JavaScript" & chr(34) & ">"
response.write "var strFirstname=" & chr(34) & sFirstname & chr(34) &";"
response.write "var strLastname=" & chr(34) & sLastname & chr(34) &";"
response.write "</SCRIPT>"
%>
4) Now, strFirstname and strLastname values are avail for us in other
Javascript code.
Since I have the ASP to JS issue solved, I will work on the JS to ASP issue
soon. Thanks.
Craig
(e-mail address removed) (remove SPAM before emailing.)