Title:JK PUZZLES
Author:R.Jeyakannan
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
input[disabled] {color:black!important;}
select[disabled] {color:black!important;}
</style>
</head>
<body bgcolor="#CCCCCC">
<center>
<h1>JK PUZZLES</h1>
<div align=right id='time1'>Time:0</div>
<div><b>Select Your Puzzle Board:</b>
<select name="select" id='puzzlenumber' onchange="puzzlefu()">
<option value="4">4</option>
<option value="8">8</option>
<option value="12" selected="selected">12</option>
<option value="16">16</option>
</select>
<div id='puzzleboard'>
<table width="200" border="1">
<tr>
<td>
<input style="width:50px" type="button" id='1' onclick="test(1)">
</td>
<td>
<input style="width:50px" type="button" id='2' onclick="test(2)" >
</td>
<td>
<input style="width:50px" type="button" id='3' onclick="test(3)" >
</td>
<td>
<input style="width:50px" type="button" id='4' onclick="test(4)" >
</td>
<td>
<input style="width:50px" type="button" id='5' onclick="test(5)" >
</td>
<td>
<input style="width:50px" type="button" id='6' onclick="test(6)" >
</td>
<td>
<input style="width:50px" type="button" id='7' onclick="test(7)" >
</td>
<td>
<input style="width:50px" type="button" id='8' onclick="test(8)" >
</td>
<td>
<input style="width:50px" type="button" id='9' onclick="test(9)" >
</td>
<td>
<input style="width:50px" type="button" id='10' onclick="test(10)" >
</td>
<td>
<input style="width:50px" type="button" id='11' onclick="test(11)" >
</td>
<td>
<input style="width:50px" type="button" id='12' onclick="test(12)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='13' onclick="test(13)">
</td>
<td>
<input style="width:50px" type="button" id='14' onclick="test(14)" >
</td>
<td>
<input style="width:50px" type="button" id='15' onclick="test(15)" >
</td>
<td>
<input style="width:50px" type="button" id='16' onclick="test(16)" >
</td>
<td>
<input style="width:50px" type="button" id='17' onclick="test(17)" >
</td>
<td>
<input style="width:50px" type="button" id='18' onclick="test(18)" >
</td>
<td>
<input style="width:50px" type="button" id='19' onclick="test(19)" >
</td>
<td>
<input style="width:50px" type="button" id='20' onclick="test(20)" >
</td>
<td>
<input style="width:50px" type="button" id='21' onclick="test(21)" >
</td>
<td>
<input style="width:50px" type="button" id='22' onclick="test(22)" >
</td>
<td>
<input style="width:50px" type="button" id='23' onclick="test(23)" >
</td>
<td>
<input style="width:50px" type="button" id='24' onclick="test(24)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='25' onclick="test(25)">
</td>
<td>
<input style="width:50px" type="button" id='26' onclick="test(26)" >
</td>
<td>
<input style="width:50px" type="button" id='27' onclick="test(27)" >
</td>
<td>
<input style="width:50px" type="button" id='28' onclick="test(28)" >
</td>
<td>
<input style="width:50px" type="button" id='29' onclick="test(29)" >
</td>
<td>
<input style="width:50px" type="button" id='30' onclick="test(30)" >
</td>
<td>
<input style="width:50px" type="button" id='31' onclick="test(31)" >
</td>
<td>
<input style="width:50px" type="button" id='32' onclick="test(32)" >
</td>
<td>
<input style="width:50px" type="button" id='33' onclick="test(33)" >
</td>
<td>
<input style="width:50px" type="button" id='34' onclick="test(34)" >
</td>
<td>
<input style="width:50px" type="button" id='35' onclick="test(35)" >
</td>
<td>
<input style="width:50px" type="button" id='36' onclick="test(36)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='37' onclick="test(37)">
</td>
<td>
<input style="width:50px" type="button" id='38' onclick="test(38)" >
</td>
<td>
<input style="width:50px" type="button" id='39' onclick="test(39)" >
</td>
<td>
<input style="width:50px" type="button" id='40' onclick="test(40)" >
</td>
<td>
<input style="width:50px" type="button" id='41' onclick="test(41)" >
</td>
<td>
<input style="width:50px" type="button" id='42' onclick="test(42)" >
</td>
<td>
<input style="width:50px" type="button" id='43' onclick="test(43)" >
</td>
<td>
<input style="width:50px" type="button" id='44' onclick="test(44)" >
</td>
<td>
<input style="width:50px" type="button" id='45' onclick="test(45)" >
</td>
<td>
<input style="width:50px" type="button" id='46' onclick="test(46)" >
</td>
<td>
<input style="width:50px" type="button" id='47' onclick="test(47)" >
</td>
<td>
<input style="width:50px" type="button" id='48' onclick="test(48)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='49' onclick="test(49)">
</td>
<td>
<input style="width:50px" type="button" id='50' onclick="test(50)" >
</td>
<td>
<input style="width:50px" type="button" id='51' onclick="test(51)" >
</td>
<td>
<input style="width:50px" type="button" id='52' onclick="test(52)" >
</td>
<td>
<input style="width:50px" type="button" id='53' onclick="test(53)" >
</td>
<td>
<input style="width:50px" type="button" id='54' onclick="test(54)" >
</td>
<td>
<input style="width:50px" type="button" id='55' onclick="test(55)" >
</td>
<td>
<input style="width:50px" type="button" id='56' onclick="test(56)" >
</td>
<td>
<input style="width:50px" type="button" id='57' onclick="test(57)" >
</td>
<td>
<input style="width:50px" type="button" id='58' onclick="test(58)" >
</td>
<td>
<input style="width:50px" type="button" id='59' onclick="test(59)" >
</td>
<td>
<input style="width:50px" type="button" id='60' onclick="test(60)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='61' onclick="test(61)">
</td>
<td>
<input style="width:50px" type="button" id='62' onclick="test(62)" >
</td>
<td>
<input style="width:50px" type="button" id='63' onclick="test(63)" >
</td>
<td>
<input style="width:50px" type="button" id='64' onclick="test(64)" >
</td>
<td>
<input style="width:50px" type="button" id='65' onclick="test(65)" >
</td>
<td>
<input style="width:50px" type="button" id='66' onclick="test(66)" >
</td>
<td>
<input style="width:50px" type="button" id='67' onclick="test(67)" >
</td>
<td>
<input style="width:50px" type="button" id='68' onclick="test(68)" >
</td>
<td>
<input style="width:50px" type="button" id='69' onclick="test(69)" >
</td>
<td>
<input style="width:50px" type="button" id='70' onclick="test(70)" >
</td>
<td>
<input style="width:50px" type="button" id='71' onclick="test(71)" >
</td>
<td>
<input style="width:50px" type="button" id='72' onclick="test(72)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='73' onclick="test(73)">
</td>
<td>
<input style="width:50px" type="button" id='74' onclick="test(74)" >
</td>
<td>
<input style="width:50px" type="button" id='75' onclick="test(75)" >
</td>
<td>
<input style="width:50px" type="button" id='76' onclick="test(76)" >
</td>
<td>
<input style="width:50px" type="button" id='77' onclick="test(77)" >
</td>
<td>
<input style="width:50px" type="button" id='78' onclick="test(78)" >
</td>
<td>
<input style="width:50px" type="button" id='79' onclick="test(79)" >
</td>
<td>
<input style="width:50px" type="button" id='80' onclick="test(80)" >
</td>
<td>
<input style="width:50px" type="button" id='81' onclick="test(81)" >
</td>
<td>
<input style="width:50px" type="button" id='82' onclick="test(82)" >
</td>
<td>
<input style="width:50px" type="button" id='83' onclick="test(83)" >
</td>
<td>
<input style="width:50px" type="button" id='84' onclick="test(84)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='85' onclick="test(85)">
</td>
<td>
<input style="width:50px" type="button" id='86' onclick="test(86)" >
</td>
<td>
<input style="width:50px" type="button" id='87' onclick="test(87)" >
</td>
<td>
<input style="width:50px" type="button" id='88' onclick="test(88)" >
</td>
<td>
<input style="width:50px" type="button" id='89' onclick="test(89)" >
</td>
<td>
<input style="width:50px" type="button" id='90' onclick="test(90)" >
</td>
<td>
<input style="width:50px" type="button" id='91' onclick="test(91)" >
</td>
<td>
<input style="width:50px" type="button" id='92' onclick="test(92)" >
</td>
<td>
<input style="width:50px" type="button" id='93' onclick="test(93)" >
</td>
<td>
<input style="width:50px" type="button" id='94' onclick="test(94)" >
</td>
<td>
<input style="width:50px" type="button" id='95' onclick="test(95)" >
</td>
<td>
<input style="width:50px" type="button" id='96' onclick="test(96)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='97' onclick="test(97)">
</td>
<td>
<input style="width:50px" type="button" id='98' onclick="test(98)" >
</td>
<td>
<input style="width:50px" type="button" id='99' onclick="test(99)" >
</td>
<td>
<input style="width:50px" type="button" id='100' onclick="test(100)" >
</td>
<td>
<input style="width:50px" type="button" id='101' onclick="test(101)" >
</td>
<td>
<input style="width:50px" type="button" id='102' onclick="test(102)" >
</td>
<td>
<input style="width:50px" type="button" id='103' onclick="test(103)" >
</td>
<td>
<input style="width:50px" type="button" id='104' onclick="test(104)" >
</td>
<td>
<input style="width:50px" type="button" id='105' onclick="test(105)" >
</td>
<td>
<input style="width:50px" type="button" id='106' onclick="test(106)" >
</td>
<td>
<input style="width:50px" type="button" id='107' onclick="test(107)" >
</td>
<td>
<input style="width:50px" type="button" id='108' onclick="test(108)" >
</td>
</tr>
<tr>
<td>
<input style="width:50px" type="button" id='109' onclick="test(109)">
</td>
<td>
<input style="width:50px" type="button" id='110' onclick="test(110)" >
</td>
<td>
<input style="width:50px" type="button" id='111' onclick="test(111)" >
</td>
<td>
<input style="width:50px" type="button" id='112' onclick="test(112)" >
</td>
<td>
<input style="width:50px" type="button" id='113' onclick="test(113)" >
</td>
<td>
<input style="width:50px" type="button" id='114' onclick="test(114)" >
</td>
<td>
<input style="width:50px" type="button" id='115' onclick="test(115)" >
</td>
<td>
<input style="width:50px" type="button" id='116' onclick="test(116)" >
</td>
<td>
<input style="width:50px" type="button" id='117' onclick="test(117)" >
</td>
<td>
<input style="width:50px" type="button" id='118' onclick="test(118)" >
</td>
<td>
<input style="width:50px" type="button" id='119' onclick="test(119)" >
</td>
<td>
<input style="width:50px" type="button" id='120' onclick="test(120)" >
</td>
</tr>
</table>
</div>
<div id='textboxvalue'></div>
<div id='score1'>Your Score : 0</div>
<input type="hidden" id='value1' />
<input type="hidden" id='first' />
<input type="hidden" id='score' value="0" />
<input type="hidden" id='Fscore' value="60" />
<script>
var textv=""
for(var i=1;i<=120;i++){
textv=textv+'<input type="hidden" id="txt'+i+'"/>';
}
//alert(textv);
document.getElementById('textboxvalue').innerHTML=textv;
function test(what){
if (document.getElementById('value1').value=="")
{
document.getElementById('value1').value=myCars[what];
document.getElementById('first').value=what;
document.getElementById(what).value=myCars[what];
document.getElementById(what).disabled=true;
}
else
{
if (document.getElementById('value1').value==myCars[what])
{
var firstvalue=document.getElementById('first').value;
document.getElementById(what).value=myCars[what];
document.getElementById(what).disabled=true;
document.getElementById(firstvalue).disabled=true;
var score=parseInt(document.getElementById('score').value)+1;
document.getElementById('score1').innerHTML="Your Score: " + score;
document.getElementById('score').value=score;
if (score==(document.getElementById('Fscore').value))
{
alert('You win');
clearTimeout(y);
}
}
else
{
document.getElementById(what).value=myCars[what];
alert("Not match pls try agin");
var firstvalue=document.getElementById('first').value;
document.getElementById(what).value="";
document.getElementById(firstvalue).value="";
document.getElementById(firstvalue).disabled=false;
}
document.getElementById('value1').value="";
document.getElementById('first').value="";
}
}
var myCars=new Array();
function in_array( what, where ){
var a=0;
for(var i=0;i<where.length;i++){
if(what == where[i]){
a++;
}
}
return a;
}
var i=1;
while (i<=120)
{
var randomnumber=Math.floor(Math.random()*60)
if (in_array(randomnumber,myCars)<=1)
{
myCars[i]=randomnumber;
//document.getElementById('txt'+i).value=randomnumber;
i++;
}
}
var b=0;
var y;
function startCount1()
{
document.getElementById('time1').innerHTML="<b>Time:"+b+"</b>";
b=b+1;
y=setTimeout("startCount1()",1000);
}
startCount1();
function puzzlefu()
{
var textv='<table width="200" border="1">';
var k=1;
var val=parseInt(document.getElementById('puzzlenumber').value);
for(var i=1;i<=document.getElementById('puzzlenumber').value;i++){
textv=textv+'<tr>';
for(var j=1;j<=document.getElementById('puzzlenumber').value;j++){
textv=textv+'<td><input style="width:50px" type="button" id="'+k+'" onclick="test('+k+')"></td';
k=k+1;
}
textv=textv+'</tr>';
}
textv=textv+'</table>';
document.getElementById('puzzleboard').innerHTML=textv;
document.getElementById('value1').value="";
document.getElementById('first').value="";
document.getElementById('score1').innerHTML="Your Score: 0";
document.getElementById('score').value=0;
myCars=new Array();
var i=1;
val1=val*val;
val2=val1/2
while (i<=val1)
{
var randomnumber=Math.floor(Math.random()*val2)
if (in_array(randomnumber,myCars)<=1)
{
myCars[i]=randomnumber;
//alert(randomnumber);
//document.getElementById('txt'+i).value=randomnumber;
i++;
}
}
b=0;
document.getElementById('Fscore').value=val2;
}
</script>
</body>
</html>


Nice Game.