laPistola Posted March 26, 2009 Share Posted March 26, 2009 My JS code <script type="text/javascript"> <!-- function picChange(id,pn) { var newcode = "<img src=\"images/testimonials/"; var newcode += pn; var newcode += "\" height=\"300\" alt=\"Before After Pictures\" />"; document.getElementById(id).innerHTML = newcode; } //--> </script> Once PHP has worked its magic the link code comes out like <a href='javascript:picChange('tp2','france_006.JPG')'><img src='images/testimonials/france_006.JPG' width='134' height='100' alt='Click to enlarge' style='margin: 0 4px;' /></a> Once you click on the image it should change the innerHTML of this <div id="tp2" class="testiPicture"><img src='images/testimonials/france_006.JPG' width='400' height='300' alt='Before/After Picture' /></div> Im passing in the ID of the div and file name to the JS as there is a few different small galleries on page, all PHP generated and works fine until the onpage image swap is called using my JS script which as normal when i write JS it didn't work . Any body have incite to why. Thank you Link to comment https://forums.phpfreaks.com/topic/151264-solved-image-swap-using-innerhtml/ Share on other sites More sharing options...
laPistola Posted March 26, 2009 Author Share Posted March 26, 2009 I fixed it realised the PHP was writing ' instead of " which was braking the JS call Link to comment https://forums.phpfreaks.com/topic/151264-solved-image-swap-using-innerhtml/#findComment-794626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.