Jump to content

Recommended Posts

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

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" />'
});

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.