Jump to content

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

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.