1

What is the easiest way to send a value from PHP to Javascript in Drupal form?

1

1 Answer 1

3

The standard way to do this in Drupal is with drupal_add_js(), using the "setting" type, e.g.:

drupal_add_js(array('variableName' => 'value'), 'setting');

That will make the variable available on the JS side at Drupal.settings.variableName.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.