Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 16 to 18 of 18
12-04-2012, 12:44 AM #16Code:
document.getElementById("card1").src = cardname1;Code:
<div id="card1"></div> ... document.getElementById("card1").innerHTML = '<img src="' + cardname1 + '" alt="random card" />';Be yourself. No one else is as qualified.
12-04-2012, 02:32 AM #17
By the by...there is a fatal flaw in my code...*AND* in your original code!
There is *NOTHING* to prevent the SAME CARD from being picked for both cards!!!
That's because you pick the two cards completely independently of each other.
The *right* way to do this is to shuffle the deck and then just deal the top two cards off the top of the deck.
But if you only ever need two cards, it's sufficient to just check the 2nd against the 1st and loop until the 2nd doesn't match the 1st.Be yourself. No one else is as qualified.
12-04-2012, 08:53 AM #18
- Join Date
- Jun 2002
- London, England
- Thanked 2,672 Times in 2,648 Posts
You don't need images - you could use the HTML codes.
&hearts &clubs &diams &spades
Shuffle is probably a bit advanced for you at this stage, but
Last edited by Philip M; 12-04-2012 at 09:16 AM.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.