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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with session variables

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
Can you use session variables created in VB script with JavaScript? How would I call them?
 
You can use this:

<html>
<body>
<%
session(&quot;xy&quot;)=3
session(&quot;name&quot;)=&quot;john&quot;
%>

<script language=javascript>
var n=<%=session(&quot;xy&quot;)%>;
var z='<%=session(&quot;name&quot;)%>';
alert('number='+n+' name='+z);
</script>

</body>
</html>

Sergio M. Netto
 
I need to store the javascript values in session variable, can you tell how can we do that.

Thanx
 
You will need to put them in a form (possibly as INPUT TYPE=hidden) and the form action is an ASP page that reads the form values and assigns them to the session vars.

You see ASP runs on the server, JavaScript runs on the client. Once the page is on the client the only way to run server side scripts (like ASP) is to call another web page.

Hope this helps, Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
How do I assign javascript variables to variables in a jsp ? or How to I get a javascript variable into my jsp ?
 
in your JSP page :

<script>
var myJSPVariable = &quot;<%= myJSPVariable %>&quot;
</script>

<body onload=&quot;document.forms[0].test.value = myJSPVariable&quot;>

<form action=anotherJsp.jsp>
<input type=text name=test>
</form>

now on anotherJsp.jsp I can do :

<%
String myJSVariable = Request.getParameter(&quot;test&quot;);
%>

Hope this helps you out. Gary Haran
 
I have javascript variable defined. I need to get that variable to into my jsp to manipulate. Can anyone help ?
 
JSP is like ASP - they are SERVER SIDE SCRIPTING LANGUAGES. So once the page is running in the browser (ie JavaScript is handling things), JSP is no longer present in the page. You will need to send the variables' values to a second page that will use them to set the JSP variables.

There is no other way. Please listen to xutopia, he didn't get on the top of the &quot;This Forum's Top Experts&quot; list by accident. Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top