Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make an image hyper-linkable from an array? 1

Status
Not open for further replies.

RRUU

Technical User
Joined
Jul 1, 2006
Messages
3
Location
NZ
How do I assign a hyperlink to an image that has been loaded from an array?
Code:
var pic = new Array(); 
pic[0] = "picture0.jpg";
pic[1] = "picture1.jpg";
pic[2] = "picture2.jpg";
pic[3] = "picture3.jpg";
pic[4] = "picture4.jpg";
var url = new Array(); 
url[0] = "url0.html";
url[1] = "url1.html";
url[2] = "url2.html";
url[3] = "url3.html";
url[4] = "url4.html";
I guess it would look something like this???
Code:
<script type="text/javascript"> 
document.write('<a href="url[0]"><img src=pic[0]/width='100' height='140'></a>'); 
</script>
Cheers
 
Anybody understand what Im trying to achieve here please?
 
May not understand.
[tt]
<script type="text/javascript">
for (var i=0;i<pic.length;i++) {
document.write('<a href="' + url+ '"><img src="' + pic + '" alt="' + pic + '" style="width:100px;height:140px;" /></a><br />');
}
</script>
[/tt]
 
Shot boss!
Youre right I didnt understand :) However I was able to modify the script your wrote to get what I wanted. Thanks a lot :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top