473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

website code to show large and full size image on click

So i have my images set up like this : http://cgi.ebay.com/Tippmann-98-paintBall-Marker-Gun-Paint-Ball_W0QQitemZ250274334261QQihZ015QQcategoryZ47248 QQssPageNameZWDVWQQrdZ1QQcmdZViewItem

Scroll down to the bottom and you see several images, One large one and then several smaller ones, when you click on the smaller ones it places a larger version of that picture in place of where the other larger picture was, well i use this method on my website but what i want to do is make it so that when you click on the smaller image and it comes up in the larger image spot, you can click on the larger image also to make it into an even bigger supersized picture, but i cant simply link the large picture because it needs to change every time for each smaller picture, so what i need it some type of code that changes the background URL of the bigger image every time you click on the smaller image, while still letting it function properly. So i need someway of being able to do this. Like everytime you click the smaller image, a large one appears in the place of the large image and also somehow makes it so that when you click the large image it also takes you to a super sized image, either by way of URL or some other form.

Any help is greatly appreciated. Sorry for the long post but it is kind of hard for me to explain.
Aug 3 '08 #1
13 29448
acoder
16,027 Expert Mod 8TB
The src property of the image will contain the URL to the full-size image. Use that to show the full-size image onclick, e.g.
Expand|Select|Wrap|Line Numbers
  1. <img ... src="whatever.png" onclick="location.href=this.src;">
or
Expand|Select|Wrap|Line Numbers
  1. <a href="original.png" onclick="this.href=document.getElementById('largeImg').src;"><img id="largeImg" src="whatever.png"></a>
or you could change the href when you change the large image onclick of the small image.
Aug 3 '08 #2
Thank you very much for your reply, tho i am not sure how to insert your code into mine since i already have an onclick event in my code, this is the code i'm using currently for my picture setup:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <tr>           
  3. <td height="399"><img src="http://dadetrader.com/Pics/PICT1591.JPG" name="productimages_" width="486" height="365" border="0" align="top"/></a></td>         
  4. </tr>         
  5. <tr>           
  6.  
  7. <td height="99" align="center" valign="top">
  8.  
  9. <a href=#productimages onclick="productimages_.src='http://dadetrader.com/pics/PICT1591.JPG'" onfocus="blur()"><img src="http://dadetrader.com/thumbnails/PICT1591.JPG" width="156" height="117" border="0"/></a>
  10.  
  11. <a href=#productimages onclick="productimages_.src='http://dadetrader.com/pics/PICT1592.JPG'" onfocus="blur()"><img src="http://dadetrader.com/thumbnails/PICT1592.JPG" width="156" height="117" border="0"/></a>
  12.  
  13. <a href=#productimages onclick="productimages_.src='http://dadetrader.com/pics/PICT1593.JPG'" onfocus="blur()"><img src="http://dadetrader.com/thumbnails/PICT1593.JPG" width="156" height="117" border="0"/</a><br></td>         
  14.  
  15. </tr>

(i spaced out the code so you can see it better)

Pretty much when i click on the 1591, 1592, 1593 small image links it then also shows up in the large image location, but what i want is after i do click on the small image link, and it does its magic, i also want the big image to now be clickable to show a supersized image, and obviously this has to change for each small image link i click. I was thinking the only way of doing this is by using some complicated javascript function or something to be able to use 2 onclick functions in 1 link/image or something like that, dont know.
Aug 3 '08 #3
acoder
16,027 Expert Mod 8TB
Try replacing the large image with
Expand|Select|Wrap|Line Numbers
  1. <a href="http://dadetrader.com/Pics/PICT1591.JPG" onclick="this.href=document.getElementById('largeImg').src;"><img id="largeImg" src="http://dadetrader.com/Pics/PICT1591.JPG" ...></a>
Aug 3 '08 #4
ok so lets say my supersized image URL would be http://www.dadetrader.com/picsbg/pict1588.jpg, and ETC, how would i use that with this code?
also ultimately i am going to incorporate a popup window with the supersized image, so when you click the large image you get a popup with the supersized image.
Aug 4 '08 #5
acoder
16,027 Expert Mod 8TB
The code would be the same or similar. The onclick changes the link href to the current source of the image (which will have been changed from clicking the small images).

To open a popup window, use window.open().
Aug 4 '08 #6
Hmm, this doesn't make much sense and is very confusing, nor does it solve the problem I'm asking at all, very unhelpful, oh well thanks anyway I will try another forum.
Aug 5 '08 #7
acoder
16,027 Expert Mod 8TB
I can't see why you think that. If you follow what I've suggested, it should solve your problem. Have you tried incorporating the changes into your code? You've not shown me what you've attempted with the code given.

If there's a part of the code that you don't understand, I could explain it to you if you want. If JavaScript is the problem, perhaps you should be consulting a tutorial first. Sure, you may get someone doing all the work for you on another forum, but that wouldn't help much by way of learning. Hope that helps.
Aug 5 '08 #8
I can't see why you think that. If you follow what I've suggested, it should solve your problem. Have you tried incorporating the changes into your code? You've not shown me what you've attempted with the code given.

If there's a part of the code that you don't understand, I could explain it to you if you want. If JavaScript is the problem, perhaps you should be consulting a tutorial first. Sure, you may get someone doing all the work for you on another forum, but that wouldn't help much by way of learning. Hope that helps.
Yea I tried putting your code in, in many different ways, but it just doesnt work out the way I want it to.

I need the big picture to link me to http://www.dadetrader.com/picsbg/pict124.jpg (for example), changing that link everytime when clicking on the smaller picture, but it only links to the same picture opening up another page, which is what the smaller pictures are linked to.... but i cant change the smaller links because then it wouldnt change the large picture at all in the first place.

Also, Its much easier to learn when I do have the entire code, It lets me understand how it works and how I could change it and mend it next time to use it in another way for something different, instead of having no idea what your telling me or no idea of seeing how what your telling me could work... which right now im sure so far what you have showed me wont work the way I need it to, and the popup part is not a problem forget about that, if we could get it to actually link to the supersized image in the first place then that would be nice (which is the whole point).
Aug 5 '08 #9
acoder
16,027 Expert Mod 8TB
OK, let's try again. In your code in post #3, replace line 2 with:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <td height="399"><a href="http://dadetrader.com/Pics/PICT1591.JPG" onclick="this.href=document.getElementById('largeImg').src;"><img id="largeImg" src="http://dadetrader.com/Pics/PICT1591.JPG" name="productimages_" width="486" height="365" border="0" align="top"/></a></td>
When the large image src property is changed, then the link href hasn't changed yet (though you could add that to each small image onclick, but let's try to keep things simple), so what the link onclick does is change the link href to point to whatever the current src of the large image is. Try it out and see what happens.
Aug 5 '08 #10
OK, let's try again. In your code in post #3, replace line 2 with:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <td height="399"><a href="http://dadetrader.com/Pics/PICT1591.JPG" onclick="this.href=document.getElementById('largeImg').src;"><img id="largeImg" src="http://dadetrader.com/Pics/PICT1591.JPG" name="productimages_" width="486" height="365" border="0" align="top"/></a></td>
When the large image src property is changed, then the link href hasn't changed yet (though you could add that to each small image onclick, but let's try to keep things simple), so what the link onclick does is change the link href to point to whatever the current src of the large image is. Try it out and see what happens.
Takes me to another page with the same picture.

Also, something a little more important if you could help me with, is i want to add a "Ask A Question" button or link to each page on my site that will have a product on it, i have a working form and form script that people can enter there name email and message and then is sent to my email, but i need a way to somehow make it so that it transmits something letting me know what page, product or URL the form was submitted, clicked from or anything just letting me know in anyway that could lead me back to the product.
Aug 5 '08 #11
acoder
16,027 Expert Mod 8TB
Takes me to another page with the same picture.
I made an (incorrect, as it transpires) assumption based on what you gave that by super-sized you meant a full size image and that the small and large images were smaller versions of this full-sized image. To answer this question, I'm going to need more information, i.e. how are you connecting these super-size images with their smaller counterparts, e.g. for PICT1591.JPG, what's the super-size version, same for PICT1592.JPG, PICT1593.JPG, etc.

Also, something a little more important if you could help me with, is i want to add a "Ask A Question" button or link to each page on my site that will have a product on it, i have a working form and form script that people can enter there name email and message and then is sent to my email, but i need a way to somehow make it so that it transmits something letting me know what page, product or URL the form was submitted, clicked from or anything just letting me know in anyway that could lead me back to the product.
I've split off this question into another thread since it doesn't relate to the question asked in this thread.
Aug 5 '08 #12
I made an (incorrect, as it transpires) assumption based on what you gave that by super-sized you meant a full size image and that the small and large images were smaller versions of this full-sized image. To answer this question, I'm going to need more information, i.e. how are you connecting these super-size images with their smaller counterparts, e.g. for PICT1591.JPG, what's the super-size version, same for PICT1592.JPG, PICT1593.JPG, etc.
well the whole point of this thread is to find a way to do that, what i was trying to do it to somehow change the link of the "large image" everytime i click on the smaller ones leading me to the supersized image URL.

let me try and give you an example..
'
___________
|..................|
|..................|
|__________|



___ ___ ___
|___| |___| |___|

ok lets say the larger box is the large img, and the smaller boxes are the smaller box.... each time i click a small image, its image gets placed at the large images spot, now what im trying to do is make it so also when i click on it, it changes the URL of the large image, so that when i click it i can link it to a supersized version of the image, which obviously needs to change for each small image.
Aug 5 '08 #13
acoder
16,027 Expert Mod 8TB
what i was trying to do it to somehow change the link of the "large image" everytime i click on the smaller ones leading me to the supersized image URL.
This was my question. What are these super-sized image URLs? You can map these images using arrays/objects, e.g.
Expand|Select|Wrap|Line Numbers
  1. var map = new Object;
  2. map[largeSrc] = supersizeSrc; // replace these with strings...
  3.  
then use this.href=map[document.getElementById('largeImg').src]
Aug 6 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: André Nęss | last post by:
Photoshop has a function called optimize to file size which tries to fit an image to some given file size. Because I need to make sure no images on a site I'm working on are larger than X KB I need...
9
by: Deepa | last post by:
Hi All, I'm facing problem displaying image of size 5000X5000 .My window size is smaller than image size so i'm not able to see the complete image.i can use scroll bars to view the image but i...
1
by: Paul Aspinall | last post by:
Hi How can I implement an easy, resusable "Click to see full size screenshot" functionality on my images? I have 2 copies of each image... one which is 'sml', and another which is the full size...
2
by: Ahmd | last post by:
Pls look at this code, i want to call this function from an image click event. CPage=Cint(Request.Form("CurrentPage")) 'get CPage value from form's CurrentPage field Select Case...
1
by: liesther2003 | last post by:
Hi i want to show mutli layer by each click, and when i click next layer the first layer should be still display, until maybe 3rd or 4th or 5th layer all are displayed, and at the end when i click...
2
kamill
by: kamill | last post by:
Dear All, I am uploading a image file and after resize the image i am saving it. My script is working fine with small size images but when i am trying to upload big size image, i am getting below...
1
by: cleary1981 | last post by:
Hi, I want to create a page for monitoring levels. I need a really large font size. 200 - 300px if possible. I have tried all the css methods using %, px, and xx-large, but none make a...
18
by: amritpalpathak | last post by:
I have made the html+javascript code.According to which when the page loaded the image size gets reduced to 50,50 and onclicking on it ,size increases to 500,500,but i done it with the one copy of ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.