Hola amigos.
Estos es gracias a desarrolloweb y especialmente a los usuarios Miguel Angel Alvarez y Gustavo Doldán.
Aquí esta la función, solo es que le manden dos parametros, el inferior y el superior y listo!
Copio todo el html para que lo prueben, pero igual, solo necesitan la función que resalto en cursiva.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Aleatorio</title>
<script>
function aleatorio(inferior,superior){
numPosibilidades = superior - inferior
aleat = Math.random() * numPosibilidades
aleat = Math.floor(aleat)
return parseInt(inferior) + aleat
}
</script>
</head>
<body>
<script>
alert(aleatorio(1, 100000000));
</script>
</body>
</html>
Espero les sirva compañeritos. Saludos.
No hay comentarios:
Publicar un comentario