Make an image hyper-linkable from an array?

If you made a template for printing or HTML export, you can offer it to the others here. You can also ask here for help about these templates
Post Reply
RRUU
Posts: 13
Joined: 2006-02-21 11:22:33
Location: NZ

Make an image hyper-linkable from an array?

Post 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
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Why do you need an array and Javascript actually? You could directly output HTML rather than Javascript.
RRUU
Posts: 13
Joined: 2006-02-21 11:22:33
Location: NZ

Post 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
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Yes now I remember that :D

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.
RRUU
Posts: 13
Joined: 2006-02-21 11:22:33
Location: NZ

Post 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!
Post Reply