GET A SESSION VARIABLE USING JAVA SCRIPT FUNCTION?

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
 1048  View(s)
Ratings:
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.

  1. Jayden Bell

    Post:110

    Points:774
    Re: get a session variable using java script function?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!