/    Sign up×
Community /Pin to ProfileBookmark

PHP/JavaScript Solution Needed

Hey,

I am a PHP person, as it is the best easy language for web design. I need to do this image gallery though, for an online store. This is my code for the popup window:

function goImgWin(myImage,myWidth,myHeight,origLeft,origTop) {
myHeight += 24;
myWidth += 24;
TheImgWin = window.open(myImage,’image’,’height=’ +
myHeight + ‘,width=’ + myWidth +
‘,toolbar=no,directories=no,location=no,status=0,menubar=no,scrollbars=no,resizable=no’);
TheImgWin.resizeTo(myWidth+2,myHeight+30);
TheImgWin.moveTo(origLeft,origTop);
TheImgWin.focus();
}

…and this is my code for the thumbnail swap image function:

image0 =new Image();
image1 =new Image();

// These 3 lines define the source of the displayed images
image0.src =”$item_smallpic”
image1.src =”$item_smallpic2″

// This defines the source of the preview image
document.images[‘thumb’].src=image0.src;
document.images[‘thumb2’].src=image1.src;

// This defines what to do when an image is clicked on
function image_click(clicks)
{
if(clicks==0){document.images[‘small’].src=image0.src;}
if(clicks==1){document.images[‘small’].src=image1.src;}
}

What I want to accomplish is when you click on the thumbnail, it changes a variable or something, so that when I retrieve it in PHP I can then change the link. This is my site, to show you what I mean: [url]http://www.heatedcold.com[/url] Click on Merch -> T-Shirts -> Middle one. Click the thumbnails and then click the bigger image. Notice how the popup image doesn’t change when you click a different thumbnail. Any help would be greatly appreciated.

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 04.2006 — When I clicked on the middle one, I got an error message before things went on to the next page. I then went back and tried the right one and got the same error message.
Copy linkTweet thisAlerts:
@KillaH425authorJun 04.2006 — You shouldn't be getting an error. I checked in both Firefox and Internet Explorer, both work for me. What was the error?
Copy linkTweet thisAlerts:
@phpnoviceJun 05.2006 — Firefox is getting the same error. I take it that you don't actually know how to check for error messages that aren't immediately and obviously displayed?
Copy linkTweet thisAlerts:
@EpsilektJun 05.2006 — Oh that's simple. Just make it so that the onclick action for your thumbnail pictures changes the link of the larger thumbnail.

Just change your onclick on the links to something like...

[CODE]<img src="big.gif" href="large.gif" /><a href="blah.jpg" onclick="changelink('newimage.jpg');">asdf</a><script language="JavaScript">function changelink(newlink) {
document.getElementById('largepicture').href = newlink;
}</script>[/CODE]
Copy linkTweet thisAlerts:
@KillaH425authorJun 05.2006 — phpnovice...i have no clue what the !@#$ ur talking about. Thank's epsilekt, but how will I be able to change back? double it up?
Copy linkTweet thisAlerts:
@EpsilektJun 05.2006 — What? Just change your links' onclick events to alter the url to change the image to. Change what back?
Copy linkTweet thisAlerts:
@KillaH425authorJun 05.2006 — I am a bit confused. I have this:

<script language="JavaScript">function changelink(link1) {

document.getElementById('smallpic').href = $link;

}

function changelink(link2) {

document.getElementById('smallpic2').href = $link2;

}</script>

And I don't understand when I am point to the anchor of the bigger picture. I already am swapping the big image when thumbnail is clicked, so I don't need to replace that.
Copy linkTweet thisAlerts:
@EpsilektJun 05.2006 — You need to change the link of the bigger image so that the source of the window you open is different corrent? Just change your open new window function so that the source of the new window depends on a variable in the image like document.getElementById('bigimage').windowurl or something. Change the changelink function so that instead of changing the href of the bigger image, change the windowurl of the image, so that when the big image is clicked on, your open window script opens that url in the new window.
Copy linkTweet thisAlerts:
@KillaH425authorJun 05.2006 — Hey,

I think I understand now, lemme try and get back to you
Copy linkTweet thisAlerts:
@KillaH425authorJun 05.2006 — I got guidance from another person. Thanks though, you helped me a lot, and if anyone seeks the solution, just ask. But I feel this is a very unique situation, and the JavaScript function is litered with PHP variables.
×

Success!

Help @KillaH425 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...