![]() |
[Java] gallery question
This is tied into this thread:
http://www.tfproject.org/tfp/showthread.php?t=76973 I have a gallery I'm trying to build located here: http://www.arch13.com/index.php?id=g...d2=test/popgal The page with two tables is included through id=gallery. The php script on the left side is then included through id2=test/popgal and builds the thumbnail table. Right now it pops up images using this code: Code:
<a href="#" onClick="popupgalimage('imgs/<?php echo $file;?>', <?php echo "$width";?>, <?php echo "$height";?>); return false" class="popimage"><? echo "<img src='imgs/thumbs/$file' class='popimage'></a></td>"."\n"; I'm also looking at how to do it using php is the referenced thread, but if I understand theFez correctly, I can only do it in php by adding another id variable to the url and refreshing the page, which doesn't seem like it would come off as proffesional. Any help, suggestions, etc are greatly appreciated. |
first of all, this is a javascript question, not a java question. the only similarity between the two is that the latter is a proper subset of the former in name only.
Basically what you need to do is name your large image, then change your onclick to swap the images. so if you change this: Code:
<img src='imgs/rail_def.jpg'> Code:
<img src='imgs/rail_def.jpg' name='master'> Code:
<a href="#" onClick="document.master.src='imgs/rail1.gif';" class="popimage"><img src='imgs/thumbs/rail1.jpg' class='popimage'></a> Code:
<body onLoad="doPreload();"> Code:
function doPreload() |
Quote:
theFez, I think I'm looking at something similar I used this page as tutorial and seem to have an understanding but can't get the image to swap http://www.alistapart.com/articles/imagegallery/ the javascript function in the pages header is this: Code:
function showPic (whichpic) { The image placeholder is Code:
<img id="placeholder" src="imgs/blank.gif" alt="" /> Code:
<a onClick="return showPic(this)" href="imgs/<?php echo $file;?>"><? echo "<img src='imgs/thumbs/$file' class='popimage'></a> If I understand your post, is this the same method? Assigning a name to the swapped image and using the image file name as the variable? Or did I miss the point completely? The current page that I've been banging on for the last three hours is here: http://www.arch13.com/galtest3.php Is what I'm doing wrong obvious to you? Or should I drop this method and try your some more? (I tried it once before posting and got back errors when I changed the imgs/rail1.gif to ?php echo $file;? (with brackets of course) |
» is not a string concatenation operator. yank that from your javascript code and it should work.
|
Quote:
Your right, that >> was screwing it up. Now that I pulled it, when I click on the image, it swaps into the right table. But then the page auto-refreshes to the image itself. I have no idea why it's doing that. Did I create something somewhere that is causing this? Maybe I should just post the page source to make it easier: As you can see, I changed the script to pull the >> tags. Is the class=popimage cuasing the page to refresh to just the image instead of the image in the table swapped? Code:
<html> |
Quote:
I used Code:
<img src='imgs/rail_def.jpg' name='master'> Then I used the following in the php thumb gallery code: Code:
<a href="#" onClick="document.master.src='imgs/<?php echo $file;?>';" class="popimage"> <? echo "<img src='imgs/thumbs/$file' class='popimage'></a> The page with your suggestion is here http://www.arch13.com/galtest4.php As for the code I've been trying mentioned above, I finally figured that I can remove Code:
if (whichpic.title) { Unfortunatly, I still can't get it to work correctly. It still just loads the clicked image in the browser window instead of swapping it into the table. Could it be becuase the onclick link and placeholder image are seperated by a TD and that is breaking the code? |
http://www.arch13.com/galtest4.php is broken. looks like you have a php error in there somewhere.
I think it might be a good idea to get the javascript working first then worry about integrating the php afterwards. |
Quote:
Good point theFez. Here's a page I banged out that contains nothing but javascript code in this thread. http://www.arch13.com/galtest5.php Still the same problem as before, works for 1sec, then simply loads the image in the browser window instead of swapping the image. I suspect the problem is with the image link, not the function but could be wrong. The link is: Code:
<p><a onclick="return showPic(this)" href="/imgs/thumbs/producefactory.jpg"><img src="/imgs/thumbs/producefactory.jpg"></a></p> Code:
<script type="text/javascript" language="JavaScript"> Code:
<img id="placeholder" src="imgs/rail_def.jpg"/> Edit: This doesn't work as it generates errors and doesn'r swap the image, but is the this a direction that would solve the problem? I've made the first of the three links in http://www.arch13.com/galtest5.php use this link to show what it does. Code:
<p><a onclick="return showPic(this)='/imgs/thumbs/producefactory.jpg'" href="#"><img src="/imgs/thumbs/producefactory.jpg"></a></p> Got http://www.arch13.com/galtest4.php workink using your method (found the parse error) It works great! I'd still like to see if I can work through this with your help though, as it's a good learning experiance for me. |
Honestly, im not seeing the problem with the script. Lots of things look weird to me in it, but I am not a javascript guru and am not entirely sure what is going on.
|
Quote:
:thumbsup: If you want to see the working finale, based on your suggestions, it's here: http://www.arch13.com/index.php?id=gallery&id2=gal Thank you for all your help. Next up I'm going to see if I can't get the pae to preload all the images based on what images are called for in the gallery script. I'm going to start of working from the code you suggested here. :crazy: |
looks good! might be a good idea to scale this one down: http://www.arch13.com/imgs/rail1.jpg so it doesnt jump the page so much.
|
All times are GMT -8. The time now is 11:42 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project