...

View Full Version : Parameter passing from server side php to client side javascript



xenonius
08-22-2011, 06:54 PM
Hi people,
I need help as follows:

On the server side I have a php generated session parameter.
I need to pass it to javascript on the client side page.

I saw on the web the following solution:

<script language="JavaScript">
var mySessionVar="<%= Session["MySessionVar"] %>";
</script>

I tried it but it did not work.

I could not find any explanation of this syntax - will appreciate one.

Any suggestions, maybe in another way?

Thanks

devnull69
08-22-2011, 07:21 PM
Long time ago I used PHP ... but <% is most definitely not PHP. Neither is Session[] which should be $_SESSION[] in PHP afaik.

Try this:


var mySessionVar="<?=$_SESSION['MySessionVar']; ?>";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum