1 回答

TA貢獻1827條經驗 獲得超8個贊
這只是一個拼寫錯誤。你的第一個id應該是,MinS但它是Mins在 HTML 方面。
var rndList = [];
var rndList2 = [];
function GD() {
var a = document.getElementById("MinS").value;
var b = document.getElementById("MaxS").value;
var c = document.getElementById("Min").value;
var d = document.getElementById("Max").value;
var e = document.getElementById("PrzNo").value;
r = [a, b, c, d, e];
return r;
}
var input = document.getElementsByClassName("o");
for (i = 0; i < input.length; i++) {
input[i].addEventListener("change", function() {
resultados = GD();
var a = resultados[0];
var b = resultados[1];
var c = resultados[2];
var d = resultados[3];
var e = resultados[4];
function raffle(MinS, MaxS, Min, Max, PrzNo) {
function getRndInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
for (i = 0; i < PrzNo; i++) {
rndList.push(getRndInt(MinS, MaxS + 1));
}
for (i = 0; i < PrzNo; i++) {
rndList2.push(getRndInt(Min, Max + 1));
}
}
raffle(a, b, c, d, e);
console.log("Serie: " + rndList);
console.log("Number: " + rndList2);
});
};
.botton {
border: 1px solid #2e518b;
padding: 10px;
background-color: #2e518b;
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
font-family: 'Helvetica', sans-serif;
border-radius: 50px;
}
.center {
display: block;
text-align: center;
width: 50%;
border: 1px dotted #f00;
padding: 8px;
margin: auto;
}
.o {}
<form action="RifaYeah.html" method="post" name="frm" onsubmit="raffle(a, b, c, d, e)">
<p class="center"> Mínima Serie: <input class="center o" type="number" name="MinS" id="MinS"><br> Máxima Serie: <input class="center o" type="number" name="MaxS" id="MaxS"><br> Mínimo Número: <input class="center o" type="number" name="Min" Id="Min"><br> Máximo Número:
<input class="center o" type="number" name="Max" id="Max"><br> Cantidad de premios: <input class="center o" type="number" name="PrzNo" id="PrzNo"><br> <input class="botton center" type="submit" value="Rifar!"> </p>
</form>
- 1 回答
- 0 關注
- 99 瀏覽
添加回答
舉報