Jump to content

Including PHP script calls in a *.js file


ceruleansin

Recommended Posts

I've been working on modifying a PHP gallery kit that can be found here. http://minishowcase.net/

 

Here is my implementation of it so far. http://ceruleansin.byethost3.com/gallery/

 

The file primarily responsible for displaying the enlarged image on the screen once you've clicked the thumbnail is /libraries/ajax.functions.js

 

In this file I've added a few lines of script. This was so that I could get a nice mouse-over effect displaying some data when I mouse over the image. The purpose was to include basic info for each image like Title, Description, Dimensions, Price and Availability.

 

Here is the code that I've added in HTML / Javascript, and yes I know this is a PHP forum, I'm getting there lol.

 


imgout += '<a href="#" class="rollover_pointer" onmouseover="document.getElementById(\'overlay\').style.visibility = \'visible\';" onmouseout="document.getElementById(\'overlay\').style.visibility = \'hidden\';"><div id="overlay" style="position: relative; top:'+(fh-64)+'px; height: 100px;" class="overlay_info"><div class="overlay_info_contents">Title:<br>Size:<br>Medium:<br>Price:</div></div></a>';

 

The "imgout" variable is added to the source contents of a <div> when the image is called from the gallery.

 

HERE IS MY PROBLEM. (About time, I know!)

 

I need to dynamically add the contents (ie. Title, Description, Dimensions, Price and Availability). There are several ways of getting the data I know of, including reading it from a text file or populating an array from a static PHP page that contains the list. Either way, I need my script to function like the following.

 

 


imgout += '<a href="#" class="rollover_pointer" onmouseover="document.getElementById(\'overlay\').style.visibility = \'visible\';" onmouseout="document.getElementById(\'overlay\').style.visibility = \'hidden\';"><div id="overlay" style="position: relative; top:'+(fh-64)+'px; height: 100px;" class="overlay_info"><div class="overlay_info_contents"><?php echo $image_array[0] ?></div></div></a>';

 

To summarize, is there a way to dynamically add info from a PHP array to a *.js file BEFORE its sent to the user?

 

Thanks for all you help!! Yay PHPFreaks!

 

PS. I've included a stripped version of my gallery in RAR. Just code, no images.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/199387-including-php-script-calls-in-a-js-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.