웹마스터 팁

<html>
<head>
<title></title>
<script language="javascript">
var no=new Array(6);
var i=0;
var cnt=0;
var result="";

function Number(){
    if(cnt<=30&&i<6){
        cnt++;
        no[i]=parseInt(Math.random()*45+1);
        document.getElementById("no"+i).innerHTML=no[i];
        setTimeout("Number()",50);
        return;
    }else{
        if(i>0){
            for(var a=0;a<no.length;a++){
                for(var b=0;b<=i;b++){
                    if(no[a]==no[i]&&a!=i){
                        cnt=25;
                        Number();
                        return;
                    }
                }
            }
        }
        cnt=0;
        i++;
        if(i<6){
            Number();
            return;
        }else{
            result="<table border='1' width='300'><tr>";
            for(var a=0;a<no.length;a++){
                result+="<td width='50' align='center'>"+no[a]+"</td>";
            }
            result+="</tr></table>";
            document.getElementById("kkk").innerHTML+=result;
            return;
        }
    }
}
function Lotto(){
    cnt=0;
    i=0;
    Number();
    return;
}
</script>
</head>
<body>
<table border="1" width="300">
    <tr>
        <td colspan="6" align="center">로또번호생성기</td>
    </tr>
    <tr align="center">
        <td width="50" id="no0">0</td>
        <td width="50" id="no1">0</td>
        <td width="50" id="no2">0</td>
        <td width="50" id="no3">0</td>
        <td width="50" id="no4">0</td>
        <td width="50" id="no5">0</td>
     </tr>
     <tr>
        <td colspan="6" align="center"><input type="button" value="click" onclick="Lotto();"/></td>
     </tr>
</table>
<div id="kkk"></div>
</body>
</html>