Page 1 of 1
Make an image hyper-linkable from an array?
Posted: 2006-06-23 15:38:38
by RRUU
How do I assign a hyperlink to an image that has been loaded from an array?
Code: Select all
var pic = new Array();
$$ITEM_BEGIN
pic[$$ITEM_NUMBER] = "$$ITEM_PICTUREFILENAME";
$$ITEM_END
I guess it would look something like this???
Code: Select all
<script type="text/javascript">
document.write('<a href="$$ITEM_FILEINDIV"><img src=pic[0]/width='100' height='140'></a>');
</script>
Cheers
Posted: 2006-06-23 18:51:53
by antp
Why do you need an array and Javascript actually? You could directly output HTML rather than Javascript.
Posted: 2006-06-24 00:52:36
by RRUU
I am trying to advance the script I made earlier
viewtopic.php?t=3073
I want it so that the images link to the movie's individual page as well as displaying ONLY the top 3.
(See my page)
http://rruu.atspace.com
Thanks
Posted: 2006-06-25 10:02:16
by antp
Yes now I remember that
rather than $$ITEM_FILEINDIV you should create the link using the base file name (e.g. 'movie_' + num + '.html')
for "num", you could use another array that will store the movie numbers, or get the last index of the "pic" array. I do not know how this can be done in JS actually, but there should be a way to get the last index of an array. If not, you have to do a "numbers" array built like the pic array I guess.
Posted: 2006-07-06 14:31:01
by RRUU
I thought so. Ive been really busy and have just got the time to look into it some more and got it working...
Example for TITLe with its URL as its link would be...
Code: Select all
var title = new Array();
$$ITEM_BEGIN
title[$$ITEM_NUMBER] = "$$ITEM_ORIGINALTITLE";
$$ITEM_END
var url = new Array();
$$ITEM_BEGIN
url[$$ITEM_NUMBER] = "$$ITEM_URL";
$$ITEM_END
And generated with...
Code: Select all
document.write('<a href="' + url[$$TOTALMOVIES]+ '">'+ title[$$TOTALMOVIES] +'</a><br />');
Great stuff!