<script type="text/javascript">
function jewel_class(num, max)
{ this.num = num; //現在の個数
this.max = max; //取り除く最大数
this.disp = function()
{
for(i=0; i<this.num; i++)
{ document.write("<img src='img/jewel.gif'>");
if (i%10==9) document.write("<br>");
}
document.write("<br>");
}
this.table = function()
{
document.write('<br><table border="1">');
document.write('<tr><td>現在の個数</td><td>');
document.write(this.num, '</td></tr>');
document.write('<tr><td>取り除く最大数</td><td>');
document.write(this.max, '</td></tr>');
document.write('</table>');
}
}
</script>
</head>
<body>
<h1>jewel Class</h1>
<h3>ブラウザの更新ボタンをクリックする度に個数が変わります。</h3>
<script type="text/javascript">
n= Math.floor(Math.random() * 10)+11;
m= Math.floor(Math.random() * 4)+2;
var cls = new jewel_class(n, m);
cls.disp();
cls.table();
</script>
|