To access PHP values and variables from JavaScript or convert php variables to JavaScript variables using Drupal 6, you can send them to your JavaScript code using Drupal's drupal_add_js function as follows:
drupal_to_js - Converts a PHP variable into its Javascript equivalent.
example -
$msg= 'hello dear'; //passing php variables to javascript
drupal_add_js("var apath = " . drupal_to_js($apath) . ";", 'inline');
Drupal_add_js(
'$(document).ready(function(){
alert(msg);
})',
'inline'
);
drupal_to_js - Converts a PHP variable into its Javascript equivalent.
example -
$msg= 'hello dear'; //passing php variables to javascript
drupal_add_js("var apath = " . drupal_to_js($apath) . ";", 'inline');
Drupal_add_js(
'$(document).ready(function(){
alert(msg);
})',
'inline'
);
So valuable keep it up.....
ReplyDeleteRESULT OF CMSP lol
great
ReplyDeleteI have read your blog its very attractive and impressive. I like it your blog.
PHP 7 Training in chennai | PHP 7 Training Course
PHP 7 Training in chennai | Online PHP 7 Course