I have hit a brick wall.
I have a simple javascript code for an image thumb with mouseover events and a js call on the link etc. which works fine.
document.write (‘<a href=”images/page_images/work/Barn4.jpg” onMouseOut=”MM_swapImage(‘mainimage’,”,’images/page_images/newbuilds-3images.jpg’, 1)” onMouseOver=”MM_swapImage(‘mainimage’,”,’images/page_images/work/Barn4_rollover.jpg’,1)” rel=”lytebox” rev=”scrolling: no;”‘><img src=”images/page_images/work/Barn4_thumb.jpg” width=”60px” height=” 60px” border=”0″></a>’);
The next stage is that these image thumbs are taken from a database so that they can be altered dynamically. I placed the javascript code in the php loop within an echo function which works perfectly fine.
echo “<script language=”javascript”>”;
echo “<a href=”images/page_images/work/” . $image . “” onMouseOut=”MM_swapImage(‘mainimage’,”,’images/page_images/newbuilds-3images.jpg’, 1)” onMouseOver=”MM_swapImage(‘mainimage’,”,’images/page_images/work/”. $image_rollover .”‘,1)” rel=”lytebox” rev=”scrolling: no;” info='<table width=”415″ border=”0″ cellpadding=”0″><tr><td width=”115″ align=”left” valign=”top”><img src=”images/page_images/work/” . $image_thumb . “”></td><td valign=”top”><p class=”worktitles”>” . $title . “<br></p><br><p class=”descriptiontext”>” . $description . “</p></td></tr></table>’><img src=”images/page_images/work/” . $image_thumb . “” width=”60″ height=”60″ border=”0″></a>”;
echo “</script>”;
The problem occurs when I try and set the width and height of the image thumb as a javascript variable. The reason it is a js variable is because it is based on a screen resolution capture.
The JS should in my mind be –
document.write (‘<a href=”images/page_images/work/Barn4.jpg” onMouseOut=”MM_swapImage(‘mainimage’,”,’images/page_images/newbuilds-3images.jpg’, 1)” onMouseOver=”MM_swapImage(‘mainimage’,”,’images/page_images/work/Barn4_rollover.jpg’,1)” rel=”lytebox” rev=”scrolling: no;”‘><img src=”images/page_images/work/Barn4_thumb.jpg” width=”‘+thumbImageWidth+’px” height=” ‘+thumbImageWidth+’px” border=”0″></a>’);
(this works btw)
and hence the final code within the php (I have split it into 3 echos to make life easier) should be –
echo “<script language=”javascript”>”;
echo “document.write (‘”;
echo “<a href=”images/page_images/work/” . $image . “” onMouseOut=”MM_swapImage(‘mainimage’,”,’images/page_images/newbuilds-3images.jpg’, 1)” onMouseOver=”MM_swapImage(‘mainimage’,”,’images/page_images/work/”. $image_rollover .”‘,1)” rel=”lytebox” rev=”scrolling: no;” info='<table width=”415″ border=”0″ cellpadding=”0″><tr><td width=”115″ align=”left” valign=”top”><img src=”images/page_images/work/” . $image_thumb . “”></td><td valign=”top”><p class=”worktitles”>” . $title . “<br></p><br><p class=”descriptiontext”>” . $description . “</p></td></tr></table>’><img src=”images/page_images/work/” . $image_thumb . “” width=””.$thumbImageWidthphp.”px” height=” “.$thumbImageWidthphp.”px” border=”0″></a>”;
echo “‘);”;
echo “</script>”;
This doesn’t work. What I get are the actual words
document.write (‘
printed on the screen, followed by the thumbnail that doesn’t have the width and height values of the javascript variable folowed by the characters
);
printed on the screen.
Thank you so much – I feel like my computer is beating me up at the moment!
And I’m a novice so please be gentle!
Best
Rob