Home > DeveloperSection > Forums > get a session variable using java script function?
marcel ethan
marcel ethan

Total Post:105

Points:735
Posted on    November-01-2014 12:24 AM

 JavaScript Session  Session Variable 
Ratings:


 1 Reply(s)
 691  View(s)
Rate this:

It may look like a stupid question, but I went through various pages since 2 days, and didn't get to a solution by myself. So I made a session variable like this:

<?php
session_start();

$_SESSION['currentpage']="home";
?>

(I checked, it does make the variable and assign it right.)

Then I tried to use it as a parameter here:

<body onload="changepage($_SESSION['currentpage'])">

It doesn't pass the variable. I tried to put it into directly the function, like not as a parameter, but inside it, doesn't work.



Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    November-01-2014 12:25 AM

You are missing the PHP tags:

<a onclick="window.open('../../Process.aspx','cal','width=490,height=420,left=500,top=180,scrollbars=no')"

href="javascript:;"><img alt="Process" src="../../images/register.gif" style="border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none" id="IMG1" onclick="return IMG1_onclick()" /></a>

<


script type="text/javascript" src="../../NoPostBacks.js">

function


IMG1_onclick() {

Session("Amount") = Me.txtAmount.Text


Session("Zip") =Me.txtZip.Text


}


</


script> - See more at: http://codeverge.com/asp.net.state-management/how-can-i-set-session-variables-with/307701#sthash.c0pM4q7S.dpuf


<body onload="changepage('<?php echo $_SESSION['currentpage']; ?>')">

Modified On Mar-22-2016 01:32:44 AM

Don't want to miss updates? Please click the below button!

Follow MindStick