Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old March 30th, 2007, 02:54 PM   #1
New Member
 

Join Date: Mar 2007
Location: Boston
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 everderese is on a distinguished road
Question how to load a different image on a web page and attach a hyperlink

Hello,
I am looking for code that will load different image on a web page and attach a hyperlink to each picture and if possible have a read artilce link associated with the image.

I did find some code that let me load the images but i can not associate a link with it.
Code:
var urls="http://www.apem.com/news/" ;
var a=[
['Joy_gr-jaune_ico.jpg',170,170,'Industrial Joysticks'],
['Serie-IA_icone.jpg',181,198,'Pushbutton Switches'],
['ACF6573.jpg',170,170,'Boots for Pushbutton Switches'],
['',,,''],
['',,,''],
['',,,''],
['',,,'']
] 

for(i=0;i<a.length;i++){a[i][0]=urls+a[i][0]};

var cflip=Math.round((a.length-1)*Math.random()) ;
document.write('<p class="h"><img src="'+a[cflip][0]+'" width="'+a[cflip][1]+'" height="'+a[cflip][2]+'" alt="'+a[cflip][3]+'"><br>'+a[cflip][3]+'<\/p>');

Last edited by karinne; March 30th, 2007 at 03:22 PM.. Reason: Please use [code]...[/code] tags when displaying code!
everderese is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 1st, 2007, 10:53 AM   #2
Most Reputable Member
 
spinal007's Avatar
 

Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,684
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0 spinal007 has a spectacular aura about spinal007 has a spectacular aura about
Re: how to load a different image on a web page and attach a hyperlink

add link tags around the code....
Code:
document.write('<p class="h"><a href="URL.htm"><img src="'+a[cflip][0]+'" width="'+a[cflip][1]+'" height="'+a[cflip][2]+'" alt="'+a[cflip][3]+'"><br>'+a[cflip][3]+'<\/a><\/p>');
__________________
Diego - Web-Developer & London SEO Expert
jQuery Plugins: Multiple File Upload, Star Rating, FCKEditor | NEW: XML to JSON
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 2nd, 2007, 11:30 AM   #3
New Member
 

Join Date: Mar 2007
Location: Boston
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 everderese is on a distinguished road
Re: how to load a different image on a web page and attach a hyperlink

Thank you

when i click on the picture it want's to go to url.htm how do i customize the line
['Joy_gr-jaune_ico.jpg',170,170,'Industrial Joysticks', url='joystick_news.html'],

looking foward to your reply
everderese is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 2nd, 2007, 11:48 AM   #4
New Member
 

Join Date: Mar 2007
Location: Boston
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 everderese is on a distinguished road
Re: how to load a different image on a web page and attach a hyperlink

Spinal007,
I figured it out, never would of got without you

Thank you
everderese is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 2nd, 2007, 12:52 PM   #5
Most Reputable Member
 
spinal007's Avatar
 

Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,684
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0 spinal007 has a spectacular aura about spinal007 has a spectacular aura about
Re: how to load a different image on a web page and attach a hyperlink

No problem and well done for trying and getting there! I hope you stick around and enjoy Webforumz...

I'll post my reply anyway because this might help somebody who comes across this post in the future.

This is an array...
['Joy_gr-jaune_ico.jpg',170,170,'Industrial Joysticks']

You went wrong by putting url= in the array...
['Joy_gr-jaune_ico.jpg',170,170,'Industrial Joysticks', url= 'NEW 1'] // ERROR

Add items to an array like this...
['Joy_gr-jaune_ico.jpg',170,170,'Industrial Joysticks', 'NEW 1', 'NEW 2']

In your case, the index of 'NEW 1' is 4 (as it's the 5th item of the array).
So you can access it using [4].

Which in your case, would be:
document.write('<p class="h"><a href="'+a[cflip][4]+'
">
<img src="'+a[cflip][0]+'" width="'+a[cflip][1]+'" height="'+a[cflip][2]+'" alt="'+a[cflip][3]+'"><br>'+a[cflip][3]+'<\/a><\/p>');
__________________
Diego - Web-Developer & London SEO Expert
jQuery Plugins: Multiple File Upload, Star Rating, FCKEditor | NEW: XML to JSON
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
different , hyperlinks , images , web papes


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Load Issue kathyc JavaScript 1 June 12th, 2008 10:21 PM
Load part of a page. magiccupcake HTML, XHTML and CSS 8 June 23rd, 2007 07:44 AM
How to use a javascript variable to load an image VanderBOOM JavaScript 2 November 13th, 2006 10:00 AM
A hyperlink that passes a variable to a page oz_egirl Classic ASP 1 January 18th, 2006 12:23 PM
image as hyperlink question bklcomputing HTML, XHTML and CSS 2 May 20th, 2005 02:56 AM


Search Engine Optimization by vBSEO 3.2.0 RC8