Buenas a todos!!! tengo un problemilla con un codigo.
Me tendria que decir si un numero sacado aleatoriamente es divisible por un numero marcado pero me siempre sale que no es divisible
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
Os pego el codigo haber si veis mi fallo.
Código:
<html>
<head>
<title></title>
<script language="javaScript">
var n=0,varboton=1, red=0, z=0;
n=parseInt(Math.random()*7000+3000);
document.write("<h2>El número ",n," es divisible entre<h2>");
function marcar (boton){
if(varboton <= 1){
if(boton.style.color=='red'){
boton.style.color='grey';
varboton--;
}
else{
boton.style.color='red';
varboton++;
}
}
else{
window.alert("Solo puede seleccionar 1 boton");
}
}
function comprobar (){
j=2;
while (j<=9){
if(div.boton2.style.color=='red'){
red=j;
}
j++;
}
if (red%n == 0){
window.alert("Es divisible!!!");
}
else{
window.alert("No es divisible");
}
}
</script>
</head>
<body>
<script language="JavaScript">
var i=0,j=2,a=1,num=0;
document.write("<form name='div'>");
while(j<=9){
document.write("<input style='width:50px;height:50px' type='button' name='boton' size='5' value='",j,"' maxlenght='30' style='color:grey' onclick='marcar(this)'>");
j++
}
document.write("<input type='button' name='boton2' value='Comprobar' onclick='comprobar();'>");
</script>
</body>
</html>
Saludos,
Javi