hiveman Posted January 21, 2008 Share Posted January 21, 2008 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 Link to comment https://forums.phpfreaks.com/topic/86975-solved-variable-problem-inbetween-single-quotes/ Share on other sites More sharing options...
Mirkules Posted January 21, 2008 Share Posted January 21, 2008 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); Link to comment https://forums.phpfreaks.com/topic/86975-solved-variable-problem-inbetween-single-quotes/#findComment-444732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.