Hello to the Users of Stack Overflow! I have a little problem, that involves if statements.
function voegelfelder(){
var va = document.getElementById("voegel").value;
if(va >= "41"){
alert("Number too high");
}
else{
document.getElementById("CB").hidden = true;
document.getElementById("CRB").hidden = false;
if(va >= "1"){
document.getElementById("v1x").hidden = false;
document.getElementById("v1y").hidden = false;
document.getElementById("v1r").hidden = false;
if(va >= "2") {
document.getElementById("v2x").hidden = false;
document.getElementById("v2y").hidden = false;
document.getElementById("v2r").hidden = false;
if(va >= "3") {
document.getElementById("v3x").hidden = false;
document.getElementById("v3y").hidden = false;
document.getElementById("v3r").hidden = false;
if(va >= "4") {
document.getElementById("v4x").hidden = false;
document.getElementById("v4y").hidden = false;
document.getElementById("v4r").hidden = false;
if(va >= "5") {
document.getElementById("v5x").hidden = false;
document.getElementById("v5y").hidden = false;
document.getElementById("v5r").hidden = false;
if(va >= "6") {
document.getElementById("v6x").hidden = false;
document.getElementById("v6y").hidden = false;
document.getElementById("v6r").hidden = false;
}
}
}
}
}
}
}
}
In that example I was checking if the Number in the textfield was 1 or if it was 2 or 3 or 4..., and if it was 3 for Example it should do everything that it does in 1, 2 and 3. That worked but if i typed 5 in there it said "Number too high" but thaht should only happen if the number is more than 40. By the way I have everything that it needs like this:
<input type="text" placeholder="Vogel 1 X" id="v1x" hidden="hidden">
<input type="text" placeholder="Vogel 1 Y" id="v1y" hidden="hidden">
<input type="text" placeholder="Vogel 1 Richtung" id="v1r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 2 X" id="v2x" hidden="hidden">
<input type="text" placeholder="Vogel 2 Y" id="v2y" hidden="hidden">
<input type="text" placeholder="Vogel 2 Richtung" id="v2r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 3 X" id="v3x" hidden="hidden">
<input type="text" placeholder="Vogel 3 Y" id="v3y" hidden="hidden">
<input type="text" placeholder="Vogel 3 Richtung" id="v3r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 4 X" id="v4x" hidden="hidden">
<input type="text" placeholder="Vogel 4 Y" id="v4y" hidden="hidden">
<input type="text" placeholder="Vogel 4 Richtung" id="v4r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 5 X" id="v5x" hidden="hidden">
<input type="text" placeholder="Vogel 5 Y" id="v5y" hidden="hidden">
<input type="text" placeholder="Vogel 5 Richtung" id="v5r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 6 X" id="v6x" hidden="hidden">
<input type="text" placeholder="Vogel 6 Y" id="v6y" hidden="hidden">
<input type="text" placeholder="Vogel 6 Richtung" id="v6r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 7 X" id="v7x" hidden="hidden">
<input type="text" placeholder="Vogel 7 Y" id="v7y" hidden="hidden">
<input type="text" placeholder="Vogel 7 Richtung" id="v7r" hidden="hidden"><br>
<input type="text" placeholder="Vogel 8 X" id="v8x" hidden="hidden">
<input type="text" placeholder="Vogel 8 Y" id="v8y" hidden="hidden">
<input type="text" placeholder="Vogel 8 Richtung" id="v8r" hidden="hidden"><br>
I am very Thankfull to everyone that helps me, because I am an Amature!
-OfficialFreak
Aucun commentaire:
Enregistrer un commentaire