Link to home
Start Free TrialLog in
Avatar of junior2e
junior2e

asked on

onClick - change href

I have a dynamic list of thumbnails, and one cooresponding "medium" sized image that changes onClick... I also need to be able to allow the user to click on this medium sized image to view the "large" image.

My JS function is as -
function showMedium(imageName) {
     document.bigImage.src = imageName;
}

This changes the medium size image, but I have a "a href" around the medium sized image that also needs to change.

<a href='???' target='new'><img name='bigImage' width='400' height='300' src='images/homes/medium/" & house_ID & ".jpg' border='0'></a>

Can I change the "href" value onClick - inside the above function?

Thanks!
Avatar of AArnie
AArnie

Sure you can,

Just add an 'id' to the Href...

<A Href="link" id="Href1" Name="Href1">links</A>

then in code...

function changeHref(){
  document.all("Href1").href="newlink"
}

AArnie.
Dont forget changeHref() needs to be called from an event some where...

AArnie.
ASKER CERTIFIED SOLUTION
Avatar of gator4life
gator4life

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
AArnie's solution will only work in Internet Explorer 4.0+, since the "all" collection is a Microsoft proprietary extension to the "document" object.  It is not recognized as a standard, and it will not work in any other browsers.  The DOM is an open standard that all modern browsers must conform to.

gator4life
(chomp, chomp)
Avatar of junior2e

ASKER

awesome, thanks for the help!
*******************************************************
******PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER******
*******************************************************
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area:
RECOMMENDATION:

 - [Points to gator4life Grade A]

Please leave any comments here within the next seven days.
*******************************************************
******PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER******
*******************************************************

jAy
EE Cleanup Volunteer