Script Categories













Games >>> Bridge.

Here is an interesting use of JavaScript, deal a hand of Bridge! Each time you load the page JavaScript will deal a new hand to four players.

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
n = new Array ("X","2","3","4","5","6","7","8","9","T","J","Q","K","A","2","3","4","5","6","7","8","9","T","J","Q","K","A","2","3","4","5","6","7","8","9","T","J","Q","K","A","2","3","4","5","6","7","8","9","T","J","Q","K","A")
m = new Array (53)
f = new Array("C ","D ","H ","S ")
g = new Array(53)
function gethand(){
var a = 52
while (a > 0){
var b = 53
var x = Math.random()
x = new String (x)
x = x.substring(x.length -5)
x = Math.round(x*.52/1000)
if (x == 0) x = 52
if (m[x] == 100) a = a+1
else if (m[x] != 100) g[a] = x
m[x] = 100
a = a -1
}
var t = 3;var s = 1;var h = 1;var d = 1;var c = 1;var b = 52;
while (b > 0){
if (t == 3) if (s == 1)document.write("<center><table><tr><td width=90></td><td width=90><font size=2><b>North</b><br>",f[3]);
if (t == 3) s = 0;
if (b < 40) t = 2;
if (t == 2) if (h == 1)document.write("<br>",f[2]);
if (t == 2) h = 0;
if (b < 27) if (b > 13) t = 1;
if (t == 1) if (d == 1)document.write("<br>",f[1]);
if (t == 1) d = 0;
if (b < 14)  t = 0;
if (t == 0) if (c == 1)document.write("<br>",f[0]);
if (t == 0) c = 0;
var cc = 13
while (cc > 0){
if (g[cc] == b)document.write(n[b])
cc = cc - 1
}
b = b - 1
}
var t = 3;var s = 1;var h = 1;var d = 1;var c = 1;var b = 52
while (b > 0){
if (t == 3) if (s == 1)document.write("</td><td width=90></td></tr><tr><td><font size=2><b>West</b><br>",f[3])
if (t == 3) s = 0
if (b < 40) t = 2
if (t == 2) if (h == 1)document.write("<br>",f[2])
if (t == 2) h = 0
if (b < 27) if (b > 13) t = 1
if (t == 1) if (d == 1)document.write("<br>",f[1])
if (t == 1) d = 0
if (b < 14)  t = 0
if (t == 0) if (c == 1)document.write("<br>",f[0])
if (t == 0) c = 0
var cc = 26
while (cc > 13){
if (g[cc] == b)document.write(n[b])
cc = cc - 1
}
b = b - 1
}
var t = 3;var s = 1;var h = 1;var d = 1;var c = 1;var b = 52
while (b > 0){
if (t == 3) if (s == 1)document.write("</td><td></td><td><font size=2><b>East</b><br>",f[3])
if (t == 3) s = 0
if (b < 40) t = 2
if (t == 2) if (h == 1)document.write("<br>",f[2])
if (t == 2) h = 0
if (b < 27) if (b > 13) t = 1
if (t == 1) if (d == 1)document.write("<br>",f[1])
if (t == 1) d = 0
if (b < 14)  t = 0
if (t == 0) if (c == 1)document.write("<br>",f[0])
if (t == 0) c = 0
var cc = 39
while (cc > 26){
if (g[cc] == b)document.write(n[b])
cc = cc - 1
}
b = b - 1
}
var t = 3;var s = 1;var h = 1;var d = 1;var c = 1;var b = 52
while (b > 0){
if (t == 3) if (s == 1)document.write("</td></tr><tr><td></td><td><font size=2><b>South</b><br>",f[3])
if (t == 3) s = 0
if (b < 40) t = 2
if (t == 2) if (h == 1)document.write("<br>",f[2])
if (t == 2) h = 0
if (b < 27) if (b > 13) t = 1
if (t == 1) if (d == 1)document.write("<br>",f[1])
if (t == 1) d = 0
if (b < 14)  t = 0
if (t == 0) if (c == 1)document.write("<br>",f[0])
if (t == 0) c = 0
var cc = 52
while (cc > 39){
if (g[cc] == b)document.write(n[b])
cc = cc - 1
}
b = b - 1
}
document.write("</td><td></td></tr></table></center>")
}
gethand();
// End -->
</script>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©