Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/09/2015, 05:02
Orbit
 
Fecha de Ingreso: septiembre-2015
Mensajes: 3
Antigüedad: 9 años, 6 meses
Puntos: 0
Como puedo sacar el id que se muestra en mi dado

Buenas, estaba haciendo un juego (un dado animado para ganar premios), el problema esque no se como puedo hacerlo de otra manera para obtener la id que se muestra aleatoria mediante un display:block, les paso el código
Código:
<html>
<head>
<title> DADO </title>
<style type="text/css">
span {display: none;}
button {display: block;}
</style>
<script type="text/javascript">
var VanillaRunOnDomReady = function() {
var boton = document.getElementById("id_boton"),
    cuarz = document.getElementsByTagName("div"),
    total = cuarz.length,
    forEach = Array.prototype.forEach;

boton.addEventListener("click", function () {
    var i = 0,
        intervalo = setInterval(function () {
            if ((i += 100) < 3000) {
                var posicion = Math.floor(Math.random() * total);
                forEach.call(cuarz, function (estilo) {
                    estilo.style.display = estilo == cuarz[posicion] ? "block" : "none";
                });
            } else clearInterval(intervalo);
        }, 100);
}, false);
}

var alreadyrunflag = 0;

if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", function(){
        alreadyrunflag=1; 
        VanillaRunOnDomReady();
    }, false);
else if (document.all && !window.opera) {
    document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>');
    var contentloadtag = document.getElementById("contentloadtag")
    contentloadtag.onreadystatechange=function(){
        if (this.readyState=="complete"){
            alreadyrunflag=1;
            VanillaRunOnDomReady();
        }
    }
}

window.onload = function(){
  setTimeout("if (!alreadyrunflag){VanillaRunOnDomReady}", 0);
}

</script>

</head>
<body>

<?php // VARIABLES DE IDS
$a = ('ID  '. 3);
$b = ('ID  '. 1);
$c = ('ID  '. 6);
$d = ('ID  '. 5);
$f = ('ID  '. 2);
$g = ('ID  '. 4);
?>
<form action="" method="post">
<div name="b" style="display: none;"><?php echo $b; ?></div>
<div style="display: none;"><?php echo $f; ?></div>
<div style="display: none;"><?php echo $g; ?></div>
<div style="display: none;"><?php echo $d; ?></div>
<div style="display: none;"><?php echo $a; ?></div>
<!-- Por defecto -->
<div style="display: block;"><?php echo $c; ?></div>
</form>
<br>
<button style="margin-left:20px;" type="submit" value="Lanzar Dado" name="button" id="id_boton">¡Lanzar!</button>



</body></html>
Les doy una imagen de como es, (aún no he echo el css ni nada, ya que no he solucionado como sacar la id)