Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Simultaneous image and link swap
Old 03-18-2009, 11:53 AM Simultaneous image and link swap
Super Talker

Posts: 133
Name: Jess Weiss
Location: Massachusetts
Trades: 0
Hi all -

I'm VERY new to javascript, so please bear with me. I'm sure this is easy to do, but I've been searching around and can't figure out how to link the different elements of what I am trying to do.

I've managed to get a script working that changes the image shown in a particular location when you hover over a link. (This is using tables for now - the CMS I work in doesn't allow creation of new styles, so please forgive that). This is what I have so far:

***
<html>
<head>
<title>Javascript Test</title>
<script language="JavaScript" type="text/JavaScript">
function showT(q){
document.getElementById('photo').setAttribute('src ','0'+ q + '.jpg')
}
</script>
</head>

<body>
<table width="500" border="0">
<tr>
<td width="20%">
<a href="#" onmouseover="showT(0)" title="physician">pic 1
<br> <br>
</a>
<a href="#" onmouseover="showT(1)" title="mouse">pic 2
<br> <br>
</a>
<a href="#" onmouseover="showT(2)" title="flower">pic 3</a>
</td>

<td><a href="#" javascript:><img id="photo" src="H:\Javascript\stimulus\00.jpg" width="100" height="100"></a></td>
</tr>
</table>
</body>
</html>
***

I seem to have lost most of my post as I edited...

What I want to do is assign different urls to the different images shown. For example, I want the image to link to one url when hovering over the link named physician, another specific url when hovering over the link named mouse and another specific url when hovering over the link named flower.

Thanks so much in advance!
__________________
"If you worried about falling off the bike, you'd never get on it" - Lance Armstrong

"The problem with people who have no vices is that generally you can be pretty sure they're going to have some pretty annoying virtues." - Elizabeth Taylor

Last edited by lynnema; 03-18-2009 at 11:56 AM..
lynnema is offline
Reply With Quote
View Public Profile Visit lynnema's homepage!
 
 
Register now for full access!
Old 03-18-2009, 12:30 PM Re: Simultaneous image and link swap
Skilled Talker

Posts: 84
Trades: 0
Looks like the src path you defined need the Absolute path .

Try some thing like

function showT(q){
document.getElementById('photo').setAttribute('src ','H:\Javascript\stimulus\0'+ q + '.jpg');
}
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
- 1-888-869-HOST(4678)
Award winning Managed Hosting -
Please login or register to view this content. Registration is FREE

Managed Dedicated Servers. Reseller Discounts. 24/7 Impressive Tech Support
HivelocityDD is offline
Reply With Quote
View Public Profile
 
Old 03-18-2009, 12:35 PM Re: Simultaneous image and link swap
Super Talker

Posts: 133
Name: Jess Weiss
Location: Massachusetts
Trades: 0
Thanks HivelocityDD for your input!

The specific images are showing fine as I hover over each link, so I don't think that is the issue.

What I want to do is turn those specific images - which are switching and working fine - into defined links. So when each image is active in the image space, it will link to a different site.

Thanks!
__________________
"If you worried about falling off the bike, you'd never get on it" - Lance Armstrong

"The problem with people who have no vices is that generally you can be pretty sure they're going to have some pretty annoying virtues." - Elizabeth Taylor
lynnema is offline
Reply With Quote
View Public Profile Visit lynnema's homepage!
 
Old 03-18-2009, 01:11 PM Re: Simultaneous image and link swap
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
give the link an ID and switch the href attribute in exactly the same way as you switch the image src attribute
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Simultaneous image and link swap
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14081 seconds with 12 queries