1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<div style="width: 6em; text-align: right;"> <p style="padding: 0;margin: 0;"> <span id="r01"></span> <span id="r02"></span> <span id="r03"></span> <span id="r04"></span> <span id="r05"></span> <span id="r06"></span> <span id="r07"></span> <hr style="padding: 0;margin: 0;"> <span id="r08"></span> <p> </div> <script> (function(document){ var tmp = 0; var sum = 0; for (var i = 1; i <= 7; i++){ tmp = (Math.floor(Math.random() * 10000000)) + 1; document.getElementById("r0" + String(i)).innerHTML = sep(tmp); sum += tmp; } document.getElementById("r08").innerHTML = sep(sum); })(document); function sep(num){ return String(num).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,'$1,'); } </script> |