3.2.0

global variable in javascript

how to set a global variable in javascript and how to pass it to PHP?
adarsh
February 2,
You would be better servered doing a Google search for PHP and Javascript variables. This is an ActiveWidgets forum and there are not that many here that are doing AW with PHP, but there are some.
Jim Hunter (www.FriendsOfAW.com)
February 3,
I am... Jim don't forget me ... PHP is my fortè, along with my list of other skillset of coding languages.

It really depends what you are trying to accomplish, you can set a JS global var and pass it the same way as any other URL. Basically you need to pass it as a $_GET variable, you can do it with $_POST too, but you need to use XMLHttpRequest and what not which I am not going to go into. Here is an easy example.

var myvar = "12345";

window.open('http://mydomain.com/mypage.php?id='+myvar,'_PARENT');


In your PHP code you access it like any other request.

mypage.php
<?php
echo $_GET['id'];
?>
Tony (www.FriendsOfAW.com)
February 3,

This topic is archived.

See also:


Back to support forum