Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 03-02-2009, 11:27 AM random image script
Junior Talker

Posts: 1
Trades: 0
hi all

i want to create a random card picker and this script works great for me. but how can i add clickable links to cards after they are generated randomly? i want the new image generated in the same place where 0.jpg is when button is clicked exactly like in the script, but with a clickable link for each card on it. i couldnt manage to add links to the images.

thanks in advance

-----------------------------------
<script language="javascript">

<!-- Begin

function show(){
var theImages = new Array()
theImages[0] = 'deck/card1.jpg'
theImages[1] = 'deck/card2.jpg'
theImages[2] = 'deck/card3.jpg'
theImages[3] = 'deck/card4.jpg'
theImages[4] = 'deck/card5.jpg'
theImages[5] = 'deck/card6.jpg'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
document.picture.src = theImages[whichImage];
}// End -->

</script>

<img src="deck/0.jpg" name="picture" />

<form>
<input type="button" value="pick a card" onclick="show()">
</form>
foreigner is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-02-2009, 03:21 PM Re: random image script
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
create an anchor element plus its attributes then set the image as anchorElement.innerHTML
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to random image script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51924 seconds with 12 queries