473,508 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display an image from co-ordinates of another

4 New Member
Hi there
I'm new to this but I need to display an image when the user clicks on a particular area of the displayed picture. I have already done this using co-ordinates and a new page for each image but this is getting messy. Ideally I want to click on part on the image, display the new image (which would be smaller that the original) part of the original picture would still be visable, have a close button on the small image leaving the original picture behind.
Many thanks in anticipation
Aug 27 '07 #1
8 1352
r035198x
13,262 MVP
Hi there
I... I have already done this using co-ordinates and a new page for each image but this is getting messy. ....
page eh? Are you using Java or Javascript?
Aug 27 '07 #2
dopy
4 New Member
page eh? Are you using Java or Javascript?
I was hoping to use javascript within html
Aug 27 '07 #3
r035198x
13,262 MVP
I was hoping to use javascript within html
You posted in the wrong forum then.
You see Java != Javascript.

I'll now move this to the Javascript forum
Aug 27 '07 #4
gits
5,390 Recognized Expert Moderator Expert
hi ...

please post some code you've already have. i assume you made an image-map? please explain in more detail what you want to do ... i think you want to click on the imagemap and want to show a detailed view for the clicked part of the image? probably within a small popup-window?

kind regards
Aug 27 '07 #5
dopy
4 New Member
hi ...

please post some code you've already have. i assume you made an image-map? please explain in more detail what you want to do ... i think you want to click on the imagemap and want to show a detailed view for the clicked part of the image? probably within a small popup-window?

kind regards
As yet I have no code but you are exactly correct in what I want to do. I have already done a similar task with images into frames but that was simple html, don't know where to start with images without the frames. Sorry for being a nuisance
Aug 27 '07 #6
gits
5,390 Recognized Expert Moderator Expert
hi ...

no problem ... we are here to help you ... ;)

first let me give you an idea on how to achieve your goal: create a div at your page and give it an id so you may simply refer to it. make it hidden with the style property 'display: none;' and visible with 'display: block;' when you click your image-map / click a close-button that should be contained by the div. have a look at the example:

Expand|Select|Wrap|Line Numbers
  1. // state should be boolean (true or false)
  2. function toggle_container(state) {
  3.     var img_container = document.getElementById('your_div_id');
  4.  
  5.     img_container.style.display = state ? 'block' : 'none'; 
  6. }
  7.  
call that onclick of the image-map-parts with true and onclick of your button with false.

now the next part: your div should contain an img-tag with an id and empty src-attrib. now we must have a list that matches your image-map-parts with a corresponding image ... may be an id and an img-src:

Expand|Select|Wrap|Line Numbers
  1. var img_list = {
  2.     'part1': 'img_src1.jpg',
  3.     'part2': 'img_src2.jpg'
  4.     // and so on ...
  5. };
  6.  
  7. // id is your image-map-part-id ;)
  8. function set_img_src(id) {
  9.     var img = document.getElementById('your_img_tags_id');
  10.  
  11.     img.src = img_list[id];
  12. }
  13.  
try something like that ... it should work. you may retrieve the mouse-coords in case you need that and set more style-properties of our container ... but first try to display the div the way i showed you :)

kind regards
Aug 28 '07 #7
dopy
4 New Member
hi ...

no problem ... we are here to help you ... ;)

first let me give you an idea on how to achieve your goal: create a div at your page and give it an id so you may simply refer to it. make it hidden with the style property 'display: none;' and visible with 'display: block;' when you click your image-map / click a close-button that should be contained by the div. have a look at the example:

Expand|Select|Wrap|Line Numbers
  1. // state should be boolean (true or false)
  2. function toggle_container(state) {
  3.     var img_container = document.getElementById('your_div_id');
  4.  
  5.     img_container.style.display = state ? 'block' : 'none'; 
  6. }
  7.  
call that onclick of the image-map-parts with true and onclick of your button with false.

now the next part: your div should contain an img-tag with an id and empty src-attrib. now we must have a list that matches your image-map-parts with a corresponding image ... may be an id and an img-src:

Expand|Select|Wrap|Line Numbers
  1. var img_list = {
  2.     'part1': 'img_src1.jpg',
  3.     'part2': 'img_src2.jpg'
  4.     // and so on ...
  5. };
  6.  
  7. // id is your image-map-part-id ;)
  8. function set_img_src(id) {
  9.     var img = document.getElementById('your_img_tags_id');
  10.  
  11.     img.src = img_list[id];
  12. }
  13.  
try something like that ... it should work. you may retrieve the mouse-coords in case you need that and set more style-properties of our container ... but first try to display the div the way i showed you :)

kind regards
Hi
Many thanks for the time you have taken, but unfortunately I am no further on. Although I have used javascripts before I have no knowledge of javascript. I need the complete script with reference as to whether it should be in the header or body of the html document. I am a retired COBOL programmer, this new stuff is a bit different. If the code wasn't for our local free newspaper(http://www.alythvoice.co.uk/) I wouldn't be bothering you. If you could find the time to post the complete script I would very much appreciate it.
Many thanks dopy.

Ps My logon name says it all.
Aug 28 '07 #8
gits
5,390 Recognized Expert Moderator Expert
hmmmm ... we are not supposed to post complete solutions here ... in case you are willing to solve the problem let us work together on it ... first ... post some html code that we may use as the base for our work from now on ... ok?

kind regards
Aug 28 '07 #9

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

Similar topics

7
8639
by: Roger Withnell | last post by:
I would like to check that an image file, selected by a user using fileUpload, is within certain parameters (width, height, filesize) and to display the image file so that the user can see the...
6
6189
by: Sandman | last post by:
I'm having some problem here... I have a javascript I've downloaded that goes through all PNG files and enables the transparency channel in them for IE5.5+ by converting them to SPAN layers with...
6
4669
by: Sandman | last post by:
I'm having some problem here... I have a javascript I've downloaded that goes through all PNG files and enables the transparency channel in them for IE5.5+ by converting them to SPAN layers with...
6
4730
by: Yeah | last post by:
I have alternate holiday headers for my web site, and I would like to display a certain image for an upcoming holiday. Examples: Christmas 12/10 - 12/26 New Years Eve 12/27 - 1/2...
5
3174
by: Paul Tomlinson | last post by:
Tabpages and Imagelists - I want to align the image to the left so I can display some text... All, I have a number of tabpages and on each tab page I currently have an image and some text, now...
0
7114
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
7321
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,...
1
7034
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...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.