I want to use $_SESSION['total']
in javascript so I can use it in a function.
What I have tried:
var total = '<%= Session["total"]%>';
Prints: <%= Session["total"]%>
var total = <?php $_SESSION['total']; ?>;
Prints Uncaught SyntaxError: Unexpected token <
var total = "<?php $_SESSION[\'total\']; ?>";
Prints <?php $_SESSION[\'total\']; ?>
Is there a way of getting the session value and use it in javascript?
EDIT: Ok, if the you are trying this in an external javascript, it doesn't work, it work when you write the script in the php, well for me.