473,758 Members | 8,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

swap image and link change help (javascript)

Hi,

Ok so on a given page I have 4 text links:

see it in black
see it in blue
see it in red
see it in green

using the standard swap image behavior, clicking on one of the above links
changes a displayed image to:

black.jpg
blue.jpg
red.jpg
green.jpg

So far no problem.

Now, I also have a set of images called:

blackL.jpg
blueL.jpg
redL.jpg
greenL.jpg

These are larger versions of the 4 images being swapped.

What I am trying to do is have a text link that says "Click to enlarge"
underneath the image on the page that when clicked will popup a window with
the corresponding "L" (large) image (I already know how to launch a popup).

So, someone clicks the text link for "see it in black", the default image
on the page swaps to "black.jpg" and the text link underneath would launch
a popup containing "blackL.jpg "

Same for see it in blue, see it in red, see it in green

I can't figure out how to make the "Click to enlarge" text link change the
popup it will call whenever someone clicks the corresponding text link
elsewhere on the page.

IOW, clicking "see it in black" makes this text link on the page:

<a href="javascrip t:;" Onclick="popupw indow(blackL.jp g)"Click to enlarge
</a>

clicking "see it in red" makes this:

<a href="javascrip t:;" Onclick="popupw indow(redL.jpg) "Click to enlarge</a>

That's pseudocode shorthand of course for an actual popup window behavior.

Did this make sense? Can someone help me?

I'm thinking I need to use an array somehow?
Mar 28 '06 #1
6 3196
RE************* *@cox.net (Lee) wrote in <e0*********@dr n.newsguy.com>:
Karl said:
Did this make sense? Can someone help me?

I'm thinking I need to use an array somehow?


Did the instructor hint that you should use an array?
That's not how I would do it.

No that was just a guess,

Can you tell me what you think I should do?
Mar 28 '06 #2
Anyone? Please, I'm out of ideas on how to do this after 8 hours of
googling. Nothing works right.
Karl said:
Did this make sense? Can someone help me?

I'm thinking I need to use an array somehow?


Did the instructor hint that you should use an array?
That's not how I would do it.

No that was just a guess,

Can you tell me what you think I should do?


Mar 29 '06 #3
Karl said on 29/03/2006 6:33 AM AEST:
Hi,

Ok so on a given page I have 4 text links:

see it in black
see it in blue
see it in red
see it in green

using the standard swap image behavior, clicking on one of the above links
changes a displayed image to:

black.jpg
blue.jpg
red.jpg
green.jpg

So far no problem.

Now, I also have a set of images called:

blackL.jpg
blueL.jpg
redL.jpg
greenL.jpg

These are larger versions of the 4 images being swapped.

What I am trying to do is have a text link that says "Click to enlarge"
underneath the image on the page that when clicked will popup a window with
the corresponding "L" (large) image (I already know how to launch a popup).

So, someone clicks the text link for "see it in black", the default image
on the page swaps to "black.jpg" and the text link underneath would launch
a popup containing "blackL.jpg "

Same for see it in blue, see it in red, see it in green

I can't figure out how to make the "Click to enlarge" text link change the
popup it will call whenever someone clicks the corresponding text link
elsewhere on the page.

IOW, clicking "see it in black" makes this text link on the page:

<a href="javascrip t:;" Onclick="popupw indow(blackL.jp g)"Click to enlarge
</a>
The href should point to the actual image, not junk. But why use an A
element at all? You want to work with an image:

<img src="black.jpg" onclick="popupw indow(this);" ... >Click to enlarge
In popupwindow:

function popupwindow(img )
{
var imgSrc = img.src.replace (/\.jpg/,'L.jpg');
...
}

[...]
I'm thinking I need to use an array somehow?


If you like to complicate things, sure.
--
Rob
Mar 29 '06 #4
rg***@iinet.net .au (RobG) wrote in
<oA************ ******@news.opt us.net.au>:
Karl said on 29/03/2006 6:33 AM AEST:
Hi,

Ok so on a given page I have 4 text links:

see it in black
see it in blue
see it in red
see it in green

using the standard swap image behavior, clicking on one of the above
links changes a displayed image to:

black.jpg
blue.jpg
red.jpg
green.jpg

So far no problem.

Now, I also have a set of images called:

blackL.jpg
blueL.jpg
redL.jpg
greenL.jpg

These are larger versions of the 4 images being swapped.

What I am trying to do is have a text link that says "Click to
enlarge" underneath the image on the page that when clicked will popup
a window with the corresponding "L" (large) image (I already know how
to launch a popup).

So, someone clicks the text link for "see it in black", the default
image on the page swaps to "black.jpg" and the text link underneath
would launch a popup containing "blackL.jpg "

Same for see it in blue, see it in red, see it in green

I can't figure out how to make the "Click to enlarge" text link change
the popup it will call whenever someone clicks the corresponding text
link elsewhere on the page.

IOW, clicking "see it in black" makes this text link on the page:

<a href="javascrip t:;" Onclick="popupw indow(blackL.jp g)"Click to
<enlarge /a>
The href should point to the actual image, not junk. But why use an A
element at all? You want to work with an image:

No. I am not trying to make the image itself a link. I need the link that
opens the popup window to be a text link. Maybe I didn't explain that
part? I thought I did.

<img src="black.jpg" onclick="popupw indow(this);" ... >Click to enlarge
In popupwindow:

function popupwindow(img )
{
var imgSrc = img.src.replace (/\.jpg/,'L.jpg');
...
}

[...]


This makes no sense to me. I can't believe in all my searching I havn't
found a clear answer to what seems like a common thing to want to do...

Mar 29 '06 #5
Karl said on 29/03/2006 4:03 PM AEST:
rg***@iinet.net .au (RobG) wrote in
<oA************ ******@news.opt us.net.au>:

Karl said on 29/03/2006 6:33 AM AEST: [...]
<a href="javascrip t:;" Onclick="popupw indow(blackL.jp g)"Click to
<enlarge /a>


The href should point to the actual image, not junk. But why use an A
element at all? You want to work with an image:


No. I am not trying to make the image itself a link. I need the link that
opens the popup window to be a text link. Maybe I didn't explain that
part? I thought I did.


The general idea is to only suggest clicking on something if something
useful will happen. Links that are dependent on script should only be
made available by script. An A element provides the opportunity to
deliver functionality without script.

If an A element is used, the href should point to something useful.
Putting an empty script statement in there is no better than an empty
string. Why not have the href at least point to the default image so
that if JavaScript isn't available at least they get to see something.
And since they don't have scripting, they can't see the alternative
thumbnails anyway.

Oh, and you shouldn't only consider fail-over if scripting is
disabled/not supported, you should also consider it where the features
of your script are not fully supported.

e.g.

<a href="blackL.jp g" onclick="return popupwindow(... );"> ... </a>
So if popupwindow() detects some feature that isn't supported, it tidies
up and returns true so the link is followed. Otherwise it does its
thing (pops up the required image) and returns false so the link
navigation is canceled.

<img src="black.jpg" onclick="popupw indow(this);" ... >Click to enlarge
In popupwindow:

function popupwindow(img )
{
var imgSrc = img.src.replace (/\.jpg/,'L.jpg');
...
}

[...]

This makes no sense to me. I can't believe in all my searching I havn't
found a clear answer to what seems like a common thing to want to do...


A better version is:

var imgSrc = img.src.replace (/\.jpg$/,'L.jpg');
to match .jpg only at the end of the string. Now you can have the
string '.jpg' elsewhere in the path, e.g.

/images/all.jpgs/black.jpg
or similar.


--
Rob
Mar 29 '06 #6
Maybe this will make more sense with an example:

http://www.rei.com/product/47985505.htm

This is almost EXACTLY what I am trying to do. Click one of the available
colors thumbnails (sprout Steel). Then Click for larger View below the
swapped image. I want exactly this effect except using text links instead
of little thumbnails and the larger view photo appears in a popup instead
of in the same window.

I'm looking through their code but it's mostly going over my head (as did
your explanations below).

The general idea is to only suggest clicking on something if something
useful will happen. Links that are dependent on script should only be
made available by script. An A element provides the opportunity to
deliver functionality without script.

If an A element is used, the href should point to something useful.
Putting an empty script statement in there is no better than an empty
string. Why not have the href at least point to the default image so
that if JavaScript isn't available at least they get to see something.
And since they don't have scripting, they can't see the alternative
thumbnails anyway.

Oh, and you shouldn't only consider fail-over if scripting is
disabled/not supported, you should also consider it where the features
of your script are not fully supported.

e.g.

<a href="blackL.jp g" onclick="return popupwindow(... );"> ... </a>
So if popupwindow() detects some feature that isn't supported, it tidies
up and returns true so the link is followed. Otherwise it does its
thing (pops up the required image) and returns false so the link
navigation is canceled.

<img src="black.jpg" onclick="popupw indow(this);" ... >Click to
<enlarge
In popupwindow:

function popupwindow(img )
{
var imgSrc = img.src.replace (/\.jpg/,'L.jpg');
...
}

[...]

This makes no sense to me. I can't believe in all my searching I
havn't found a clear answer to what seems like a common thing to want
to do...


A better version is:

var imgSrc = img.src.replace (/\.jpg$/,'L.jpg');
to match .jpg only at the end of the string. Now you can have the
string '.jpg' elsewhere in the path, e.g.

/images/all.jpgs/black.jpg
or similar.


Mar 29 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1814
by: Wlad | last post by:
Hi, Does anybody knows how to make the browser lauch an external image editor (i.e. Photoshop) when the user clicks on a link like this : <a href= "http://localhost/images/200411081456170.Nenuphars.jpg">Image</a> The same application can be launched for any image link. Thank you. Wlad
4
44087
by: zborisau | last post by:
Hey good people, I've been given a problem to solve recently - and stuck with the solution for a good 4 days already. i have a link which leads to popup window. the purpose of that popup window is to redirect user to the one of available servers. so i need to check which server is available. i have decided to download some 1pixel image from every server and if it was downloaded
2
17575
by: Madame Blablavatsky | last post by:
hello, i have an image that is also a link: <a href="javascript:opmaak('bold','')"><img src='bold_uit.gif name='uit'></a> when the image/link is clicked it triggers a javascript that enables people to type bold.
5
1702
by: Mel | last post by:
i like to place an image link on my page that stays up for 2 seconds and user can interact with. if no interaction in 2 seconds the image and the link should disapear please help
2
1744
by: Barkster | last post by:
I have a image that I want to click and when clicked that image will be swapped and then show a hidden div. When another image like it is clicked it will swap image and hide that text and so on. My problem is that when I send the Image ID's to the function I cannot find a way to insert the dynamic names. I thought I could get the ID and concate the string to use in the function but if I do IM = "I"+id; and stick it in IM.SRC = ... it...
6
5855
by: fredo | last post by:
A few days ago, Jim answered (THANK YOU, Jim) my question about how to make an image pop up when an image link is hovered. That discussion is here: http://groups.google.com/group/comp.infosystems.www.authoring.stylesheets/browse_thread/thread/e9a21d6f46ac7168/40b2599e189fce58?hl=en#40b2599e189fce58 Jim's stylesheet made everything work beautifully in FF; and in IE, too. But when I changed his stylesheet to display thumbnails...
4
11508
by: lemat | last post by:
Hi, I use a radio button form in which users can select a color by clicking on a image. I would like this image to change to another one when it's chosen. (image with a "Chosen" Stamp in the middle) Of course I like it to be restored if hte user select another color. I've tried to add behaviour to the image (swap on click) and on the button (onchange swap restore) but it doesn't work (hte image id swapped and restored almost instantly).
3
2023
by: PEJO | last post by:
I'm not much of a JS programmer so I used the the standard Macromedia swap image function for a disjointed rollover..which works fine.. no problem swapping the image with that code.... but when I add the following to the onMouseOver to the thumbnail: onMouseOver="Product_Link.href='http://glasstoilets.com/catalog/tank1-p-28.html'; and this to the full size...
3
6120
by: zion | last post by:
Hello, How can I return image link with webservice that I could see it in web page? The image is on my hard disk and <img src="c:\pictures\test.jpg" /does not work. If I use <img src=http://My comuter/Virtual directory/test.jpg /it's working but I can't use this because the image path is in DB with phisycal location. Thanks
0
9317
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10090
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9924
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9758
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7310
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6580
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3423
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2719
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.