Ciao tutti ragazzi. Sto cercando di fare il gioco dei dadi in javascript e vorrei aggiungere la funzione random, in modo che i dadi compaiano in modo random e non in modo crescente come vanno ora, come faccio?
codice:
<!DOCTYPE html>
<html>
<head>
    <title>Lancio del dado</title>
<script type="text/javascript">
var numero_dado = 1;
var tempo =1000;
setTimeout(function(){lancio_dado(); }, tempo);
</script>
<style>
table{
 *border-collapse: collapse; /* IE7 and lower */
  border-spacing: 0;  
    background:#ffffff !important; /* For IE*/ 
}
.bordered {
  border: solid #ccc 10px;
    -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
    behavior: url(border-radius.htc);
  -webkit-box-shadow: 0 1px 1px #ccc; 
  -moz-box-shadow: 0 1px 1px #ccc; 
  box-shadow: 0 1px 1px #ccc;         
}
</style>
</head>
<body>
<script type="text/javascript">


function lancio_dado(){
    if(numero_dado == 1){
        document.getElementById('primacella').innerHTML = "";
        document.getElementById('secondacella').innerHTML = "";
        document.getElementById('terzacella').innerHTML = "";
        document.getElementById('quartacella').innerHTML = "";
        document.getElementById('quintacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('sestacella').innerHTML = "";
        document.getElementById('settimacella').innerHTML = "";
        document.getElementById('ottavacella').innerHTML = "";
        document.getElementById('nonacella').innerHTML = "";
        numero_dado = 2;
        setTimeout(function(){lancio_dado(); }, tempo);
        breake();
    }
    if(numero_dado == 2){
        document.getElementById('primacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('secondacella').innerHTML = "";
        document.getElementById('terzacella').innerHTML = "";
        document.getElementById('quartacella').innerHTML = "";
        document.getElementById('quintacella').innerHTML = "";
        document.getElementById('sestacella').innerHTML = "";
        document.getElementById('settimacella').innerHTML = "";
        document.getElementById('ottavacella').innerHTML = "";
        document.getElementById('nonacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        numero_dado = 3;
         setTimeout(function(){lancio_dado(); }, tempo);
         breake();
    }
    if(numero_dado == 3){
        document.getElementById('primacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('secondacella').innerHTML = "";
        document.getElementById('terzacella').innerHTML = "";
        document.getElementById('quartacella').innerHTML = "";
        document.getElementById('quintacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('sestacella').innerHTML = "";
        document.getElementById('settimacella').innerHTML = "";
        document.getElementById('ottavacella').innerHTML = "";
        document.getElementById('nonacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        numero_dado = 4;
         setTimeout(function(){lancio_dado(); }, tempo);
         breake();
    }
    if(numero_dado == 4){
        document.getElementById('primacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('secondacella').innerHTML = "";
        document.getElementById('terzacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('quartacella').innerHTML = "";
        document.getElementById('quintacella').innerHTML = "";
        document.getElementById('sestacella').innerHTML = "";
        document.getElementById('settimacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('ottavacella').innerHTML = "";
        document.getElementById('nonacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        numero_dado = 5;
         setTimeout(function(){lancio_dado(); }, tempo);
         breake();
    }
    if(numero_dado == 5){
        document.getElementById('primacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('secondacella').innerHTML = "";
        document.getElementById('terzacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('quartacella').innerHTML = "";
        document.getElementById('quintacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('sestacella').innerHTML = "";
        document.getElementById('settimacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('ottavacella').innerHTML = "";
        document.getElementById('nonacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        numero_dado = 6;
         setTimeout(function(){lancio_dado(); }, tempo);
         breake();
        
    }
    if(numero_dado == 6){
        document.getElementById('primacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('secondacella').innerHTML = "";
        document.getElementById('terzacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('quartacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('quintacella').innerHTML = "";
        document.getElementById('sestacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('settimacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        document.getElementById('ottavacella').innerHTML = "";
        document.getElementById('nonacella').innerHTML = "<img src='./img/punto.jpg'  width='50' height='50'>";
        numero_dado = 1;
         setTimeout(function(){lancio_dado(); }, tempo);
         breake();
        
    }
}


function lancio_dadi(){
}
</script>
<button onclick="lancio_dadi">Lancia il dado</button>
<center>
<table  class= "bordered" width ="300" height="300">
    <tr>
        <td align="center" valign="middle" width="100" height="100"><span id="primacella"></span></td>
        <td align="center" valign="middle" width="100" height="100"><span id="secondacella"></span></td>
        <td align="center" valign="middle" width="100" height="100"><span id="terzacella"></span></td>
    </tr>
    <tr>
        <td align="center" valign="middle" width="100" height="100"><span id="quartacella"></span></td>
        <td align="center" valign="middle" width="100" height="100"><span id="quintacella"></span></td>
        <td align="center" valign="middle" width="100" height="100"><span id="sestacella"></span></td>
    </tr>
    <tr>
        <td align="center" valign="middle" width="100" height="100"><span id="settimacella"></span></td>
        <td align="center" valign="middle" width="100" height="100"><span id="ottavacella"></span></td>
        <td align="center" valign="middle" width="100" height="100"><span id="nonacella"></span></td>
    </tr>
</table>
</center>


</body>
</html>