Solarpitch Posted December 28, 2006 Share Posted December 28, 2006 Hey Guys, Just wanted to know if the following format is correct, doesnt seem to be working for me at all.[code]<?php $image1 = "fusion_02.jpg";$image2 = "fusion_03.jpg";$image3 = "fusion_04.jpg";?>function image (img) {document.images['image'].src = img;}<a href="javascript:image('designs/"<?php $image1; ?>"');">1</a><a href="javascript:image('designs/"<?php $image2; ?>"');">2</a><a href="javascript:image('designs/"<?php $image3; ?>"');">3</a>[/code]Bascially, it changes the image on a page based on the number that is selected. It seems to work when I have it like below, but not above. Just wondering if the above is the correct way to embed the PHP content?This way works fine...[code]<a href="javascript:image('designs/fusion_03.jpg');">1</a><a href="javascript:image('designs/fusion_03.jpg');">2</a><a href="javascript:image('designs/fusion_04.jpg');">3</a>[/code] Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 28, 2006 Share Posted December 28, 2006 [code]<a href="javascript:image('designs/"<?php echo $image1; ?>"');">1</a><a href="javascript:image('designs/"<?php echo $image2; ?>"');">2</a><a href="javascript:image('designs/"<?php echo $image3; ?>"');">3</a>[/code]That should doTed Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted December 28, 2006 Author Share Posted December 28, 2006 Yeah, I tried that already and it doesnt seem to work either. hahah Its really strange Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 28, 2006 Share Posted December 28, 2006 try <?php echo $image3; ?> separatly, so they are not in any html tags to see if the content comes out is correct or not, then you can be more definite with the problemTed Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted December 28, 2006 Author Share Posted December 28, 2006 Yeah, that prints "fusion_04.jpg ". so it seems to be passing it through fine! Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 28, 2006 Share Posted December 28, 2006 Sorry, i dont know what the problem is then... Quote Link to comment Share on other sites More sharing options...
craygo Posted December 28, 2006 Share Posted December 28, 2006 So what you want to do is have a default image load up and if someone selects one of the other pictures it will change instantly??Ray Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted December 28, 2006 Author Share Posted December 28, 2006 Thanks anyway Ted :)Hi Ray, Yes, thats correct. It works fine but not when I call the image using the variables. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted December 28, 2006 Author Share Posted December 28, 2006 The default image will be the first image in the result. There will be 3 images displayed and $image 1 will be the default. I also have the following line of code in my "php_database" page.[code]<img name='image' src='designs/".$image1."' style='border: 1px solid rgb(0, 0, 0);' border='0' width='200' height='200' title='blah' />[/code] Quote Link to comment Share on other sites More sharing options...
craygo Posted December 28, 2006 Share Posted December 28, 2006 can you post the entire code, or at least the entire javascript part, cause I am trying to recreate and it seems to be incomplete.Ray Quote Link to comment Share on other sites More sharing options...
solarisuser Posted December 28, 2006 Share Posted December 28, 2006 Maybe you need to escape the " around the filename, as you have four double quotes per line? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 28, 2006 Share Posted December 28, 2006 Why do you have the double quotes surrounding the value echoed via PHP?[code]<a href="javascript:image('designs/"<?php echo $image1; ?>"');">1</a><a href="javascript:image('designs/"<?php echo $image2; ?>"');">2</a><a href="javascript:image('designs/"<?php echo $image3; ?>"');">3</a>[/code]Remove those double quotes and it should be ok:[code]<a href="javascript:image('designs/<?php echo $image1; ?>');">1</a><a href="javascript:image('designs/<?php echo $image2; ?>');">2</a><a href="javascript:image('designs/<?php echo $image3; ?>');">3</a>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted December 28, 2006 Author Share Posted December 28, 2006 Hi Guys,Na . . I tried that already! Still no Joy . . I bet its something god dam simple . . heres my code againview_ad.php[code]<?php$image1 = "fusion_02.jpg"; //I'll be calling these from a DB when I get it working$image2 = "fusion_03.jpg";$image3 = "fusion_04.jpg";?>script>function image (img) {document.images['image'].src = img;}</script><a href="javascript:image('designs/<?php echo $image1; ?>');">1</a><a href="javascript:image('designs/<?php echo $image2; ?>');">2</a><a href="javascript:image('designs/<?php echo $image3; ?>');">3</a>[/code]php_database.php[code]<h1 class='underline'>New Callaway Big Bertha <span>(Uploaded on: 17-12-2006)</span?></br><div id='container'> <h1 class='underline'> <div id='images'> <img name='image' src='designs/".$image1."' style='border: 1px solid rgb(0, 0, 0);' border='0' width='200' height='200' title='blah' /> The above line displays the image**************************************** </div> <div id='details'> <ul> <li><span>Section:</span> Mens</li> <li><span>Class:</span> Drivers</li> <li><span>Make:</span> Callaway</li> </ul> <ul> <li><span>Tel:</span> 0876141487</li> <li><span>Contact Name:</span> Andrew</li> <li><span>County:</span> Dublin</li> </ul> </div> <div id='text'> <p> Brand new Callaway Big Bertha Driver. Comes with 65 stiff graffaloy shaft, 9 degree loft and original head cover. No Time wasters, first to see will buy. <div class='clearb'></div> <h2 class='underline'>Price: €400</div>[/code] Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted December 28, 2006 Author Share Posted December 28, 2006 Thanks a million for all the help guys. I was messing around with it, havent a clue what I done but its decided to work now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.