Ehh... I should have made it clear in the last thread that #2 is already covered. Reusing my prototype function defined there, you can do something like:
Code:
<style type="text/css">
.even td{background-color:#eeeeee;}
.odd td{background-color:#dddddd;}
</style>
<script type="text/javascript">
//Array.prototype.dealHand
//Author: Ultimater
Array.prototype.dealHand=function(n){
var hand=new Array(),l=this.length;
for(var i=0;i<l;i++)hand.splice(Math.floor(Math.random()*(i+1)),0,i);
return hand.splice(0,n);
}
</script>
<script type="text/javascript">
deck=new Array("A","K","Q","J",10,9,8,7,6,5,4,3,2);
function newHand(){
h=deck.dealHand(5);
cards=new Array();
for(var i=0;i<h.length;i++)cards.push(deck[h[i]]);
return cards;
}
document.write("<table>");
document.write("<tr><th>One</th><th>Two</th><th>Three</th><th>Four</th><th>Five</th></tr>");
for(i=0;i<10;i++){
document.write("<tr class=\""+((i%2==0)?"even":"odd")+"\"><td>"+(newHand().join("</td><td>"))+"</td></tr>");
}
document.write("</table>");
</script>
Bookmarks