Jump to content

Recommended Posts

I am using a script that shows and hids a div.  The script works great if I write the name of the div in between single quotes. :)  Example:

 

      <input type="image" onClick="toggleBox('name_of_div',1);" value="Show Div" src="images/bookcoversmall.gif" width="137" height="200" />

 

I am trying to use the same script in a php code for a store.  I want to have a list of thumbnails of the products generated on the page and when they mouseover the thumbnail it shows a div which contains details about the product.  I am able to generate a specific div name for each product using a Variable ( $Name ) which calls up the name of the product and collapsing any spaces in the name and attaching _thumbnailzoom.  So if the product name is Honey Bear it would generate a div id of HoneyBear_thumbnailzoom.  I need to generate the exact same word inbetween the singlequotes in the above code for the name of the div.  So the generated code should output the following:

 

    <input type="image" onClick="toggleBox('HoneyBear_thumbnailzoom',1);" value="Show Div" src="images/bookcoversmall.gif" width="137" height="200" />

 

 

This is the code I am currently using:

 

<?php

     

              $array = array($Name, '_thumbnail_zoom');

              $comma_separated = implode("", $array);

 

        ?>

     

     

      <input type="image" onmouseover="toggleBox('$comma_separated',1);" value="Show Div" onmouseout="toggleBox('$comma_separated',0);" value="Hide Div" src="<?=$Thumbnail_Image?>" border="0" width="<?=$Thumbnail_Image_Width?>" height="<?=$Thumbnail_Image_Height?>" alt="<?=$Name?>" /></a></a>

 

 

:'(Unfortunately its not working for me.  I've tried removing the single quotes and its not working either.  Help from someone who knows what they are doing would be greatly appreciated. 

 

  - signed Honeyman

       

 

You need to add:

 

toggleBox('<?=$comma_separated?>',1);

 

Basically, you want the PHP interpreter to, ahem, interpret your variable. Another way to do this is (the above is just shorthand):

 

toggleBox('<?php echo $comma_separated; ?>',1);

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.