phpmady Posted June 9, 2010 Share Posted June 9, 2010 Hi, this is my js file, and i am in need of php variable passing to the js file $(document).ready(function() { $('div.menu_list').cluetip( { width:570, cluetipClass: 'jtip', arrows: true, dropShadow: false, hoverIntent: true, sticky: true, positionBy: 'mm', hoverClass: 'highlight', mouseOutClose: true, closePosition: 'title', leftOffset: 0, closeText: '<img src="plug/cluetip/stop_win.png" alt="close" />' }); }); I want to make a dir path in above line: closeText: '<img src="_DIR_plug/cluetip/stop_win.png" alt="close" />' Hope you guys help me to solve Thanks Link to comment https://forums.phpfreaks.com/topic/204286-how-to-pass-a-php-variable-in-js-file/ Share on other sites More sharing options...
JonnoTheDev Posted June 9, 2010 Share Posted June 9, 2010 Save it as a php file! Simple Link to comment https://forums.phpfreaks.com/topic/204286-how-to-pass-a-php-variable-in-js-file/#findComment-1069934 Share on other sites More sharing options...
Psycho Posted June 9, 2010 Share Posted June 9, 2010 As Neil suggests change the somefile.js to somefile.php and include the necessary code to define and write the _DIR_ value into the file. Of course you need to change any of the files that call the js file to point to the new file name: <?php // Insert code to define _DIR_ ?> $(document).ready(function() { $('div.menu_list').cluetip( { width:570, cluetipClass: 'jtip', arrows: true, dropShadow: false, hoverIntent: true, sticky: true, positionBy: 'mm', hoverClass: 'highlight', mouseOutClose: true, closePosition: 'title', leftOffset: 0, closeText: '<img src="<?php echo _DIR_; ?>plug/cluetip/stop_win.png" alt="close" />' }); Link to comment https://forums.phpfreaks.com/topic/204286-how-to-pass-a-php-variable-in-js-file/#findComment-1069940 Share on other sites More sharing options...
phpmady Posted June 9, 2010 Author Share Posted June 9, 2010 Save it as a php file! Simple thank you neil Johnson solved Link to comment https://forums.phpfreaks.com/topic/204286-how-to-pass-a-php-variable-in-js-file/#findComment-1069958 Share on other sites More sharing options...
phpmady Posted June 9, 2010 Author Share Posted June 9, 2010 As Neil suggests change the somefile.js to somefile.php and include the necessary code to define and write the _DIR_ value into the file. Of course you need to change any of the files that call the js file to point to the new file name: <?php // Insert code to define _DIR_ ?> $(document).ready(function() { $('div.menu_list').cluetip( { width:570, cluetipClass: 'jtip', arrows: true, dropShadow: false, hoverIntent: true, sticky: true, positionBy: 'mm', hoverClass: 'highlight', mouseOutClose: true, closePosition: 'title', leftOffset: 0, closeText: '<img src="<?php echo _DIR_; ?>plug/cluetip/stop_win.png" alt="close" />' }); thank You mjdamato As you said i use the REQUEST_URI method to get the root directory Thanks Link to comment https://forums.phpfreaks.com/topic/204286-how-to-pass-a-php-variable-in-js-file/#findComment-1069960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.