11 Years
Discussion Span
Last Post by tgreer

Simply add the href (anchor) tags around your image source. You can change the href property programatically, just as you are doing with the src property of the images.


Unfortunately I cannot figure out how to do that. I am not a real developer I know enough to get by. An example would really help.


I mean, just do what you are already doing. Modify your image tag to be within an anchor tag:

<img name=picture src="img/iamge_main.jpg" width="528" height="228" border="0">

That's what you have now. Add an anchor (I also removed the "name" tag as it is deprecated, changing it to the "ID" tag, and wrapped the value in quotes).

<a id="picture_link" href=""><img id="picture" src="img/iamge_main.jpg" width="528" height="228" border="0"></a>

There, now you have a link. To change the link destination, you'd revise your JavaScript: function (you have to revise it anyway to be compliant and use the "id" property instead of "name"):

function doButtons(picimage) 
  document.getElementById('picture').src = picimage + ".src";
  document.getElementById('picture_link').href = "http://www.daniweb.com";

That should work, though I haven't tested it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.