Community Documentation

HOWTO: Pass PHP variables to JavaScript

Last updated September 1, 2011. Created by mr.baileys on March 12, 2007.
Edited by batigolix, gagarine, Kasper Souren, aj045. Log in to edit this page.

Passing PHP variables to JavaScript is explained in the The Drupal JavaScript API

Comments

There is a simpler method

There is a simpler method that is described here: http://wtanaka.com/node/7813.

use "setting" as second variable.

Rougthly, your variables will be available in this array: Drupal.settings

API is here: http://api.drupal.org/api/function/_drupal_add_js/5 (_drupal_add_js is called by drupal_add_js)

--
mag{nus,oo}
http://magooweb.com/
http://magnus.anderssen.ch/

Page status

About this page

Drupal version
Drupal 6.x
Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here