Skip to content

Instantly share code, notes, and snippets.

@backy22
Created April 13, 2015 13:34
Show Gist options
  • Save backy22/19f039be81f89114f712 to your computer and use it in GitHub Desktop.
Save backy22/19f039be81f89114f712 to your computer and use it in GitHub Desktop.
<?php
$bingo = array();
for ($i=0; $i<5; $i++) {
$numbers = range($i*15+1, $i*15+15);
shuffle($numbers);
$bingo[$i] = array_slice($numbers, 0, 5);
}
$s = "";
for ($j=0; $j<5; $j++){
$s .= "<tr>";
for ($k=0; $k<5; $k++){
$s .= ($j==2 && $k==2)? "<td></td>": sprintf("<td>%s</td>",$bingo[$k][$j]);
}
$s .= "</tr>";
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>BINGO</title>
</head>
<style>
td, th {
width: 50px;
border: 1px solid #ccc;
text-align: center;
}
</style>
<body>
<p><input type="button" value="次のボール" onclick="GetRandomNumber(); alert('え');"></p>
<p><span id="sample"></span></p>
<table>
<?php echo $s; ?>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function GetRandomNumber() {
var randnum = 1+Math.floor( Math.random() * 75 );
document.getElementById("sample").innerHTML = randnum;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment