Pass PHP variables to Javascript in Drupal 6

2008 April 28

To access PHP values and variables from Javascript using Drupal, you can send them to your javascript code using Drupal's drupal_add_js as follows:

drupal_add_js(array('mymodule' => array(
'username' => 'Mike',
'uid' => 123,
'likes' => array('ice cream', 'peanuts', 'coffee'),
)), 'setting');

read more…

Advertisements

Comments are closed.

%d bloggers like this: