I've created a variable with keys and values which looks like:
var e = new Array();
e[0] = "Bitte";
e[1] = "Danke";
Besides this I added a line in the variable which shows a text when the number is undefined.
e[NaN] = "Change Settings";
So when the variable e is NaN ("undefined"), I want that he doesn't displays the Number of the variable e in the input. I tried to achieve this as you can see, but it won't function.
if (neuezahl = NaN) {
document.getElementById("saveServer").value="";
} else {
document.getElementById("saveServer").value=""+neuezahl+"";
}
You have assigned neuzahl not compared it, aside that use the isNAN function:
if (isNAN(neuezahl))
{
document.getElementById("saveServer").value="";
}
else
{
document.getElementById("saveServer").value=""+neuezahl+"";
}
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN
NaN can't be compared directly (it's not even equal to itself NaN === NaN ==> false). Use isNaN() to detect NaN:
if (isNaN(neuezahl)) {...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With