Ich habe ein Problem mit einer meiner Javascript-Funktionen gerannt. Ich versuche, eine ganze Zahl durch eine Ganzzahl zu teilen und NaN als Ergebnis zu erhalten. Ich habe verschiedene mögliche Lösungen gelesen und ausprobiert, konnte aber nicht die richtige Antwort finden. Bitte sehen Sie sich den folgenden Code an (laden Sie ihn, wenn Sie wollen) und lassen Sie mich wissen, wie ich es beheben kann, wenn Sie können. DankDivision Equation: gibt NaN zur Zeit
<!doctype html>
<html>
<style>
*:focus {
outline: none;
}
@font-face {
font-family: systems_analysis;
src: url(systems_analysis.ttf);
}
@font-face {
font-family: eufont;
src: url('eufont.ttf');
}
.button {
background-color: white;
color: black;
border-radius: 6px;
border: none;
cursor: pointer;
width: 400px;
height: 20px;
font-size: 15px;
font-family: systems_analysis;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2), 0 1.5px 5px 0 rgba(0,0,0,0.19);
}
.button:hover {
background-color: black;
color: white;
}
.button:active {
transform: translateY(1px);
}
.button:focus {
outline:0 !important;
}
.balanceBox {
background-color: transparent;
color: white;
font-family: arial;
font-size: 40px;
border: 1px transparent;
text-align: center;
width: 400px;
}
.priceBoxAltra {
background-color: transparent;
color: white;
font-family: arial;
font-size: 40px;
border: 1px transparent;
text-align: center;
width: 225px;
}
.priceBoxBexa {
background-color: transparent;
color: white;
font-family: arial;
font-size: 40px;
border: 1px transparent;
text-align: center;
width: 225px;
}
body {
background-image: url("risefx_background.jpg");
}
</style>
<head>
<title>RiseFX</title>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<center>
<span><input type="text" id="altraPrice" class="priceBoxAltra" value="1.00000"></span>
<span><input type="text" id="bexaPrice" class="priceBoxBexa" value="1.00000"></span>
</center>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<center>
<input type="text" id="fxPrice" class="priceBoxAltra" value="0.00000">
</center>
<br>
<center>
<span><input type="button" id="altraRoll" class="button" value="TRADE" onclick="altraFunction()"></span>
<span><input type="button" id="bexaRoll" class="button" value="TRADE" onclick="bexaFunction()"></span>
</center>
<br>
<br>
<center>
<input type="text" id="balance" class="balanceBox" value="1.0000000000" readonly>
</center>
<script>
function altraFunction() {
var altraRollVar = (Math.random()*2);
document.getElementById("altraPrice").value = altraRollVar.toFixed(5);
fxPriceConversion();
}
</script>
<script>
function bexaFunction() {
var bexaRollVar = (Math.random()*2);
document.getElementById("bexaPrice").value = bexaRollVar.toFixed(5);
fxPriceConversion();
}
</script>
<script>
function fxPriceConversion() {
var altraRollBoxVar = document.getElementById("altraRoll").value;
var bexaRollBoxVar = document.getElementById("bexaRoll").value;
var conversion = altraRollBoxVar/bexaRollBoxVar;
document.getElementById("fxPrice").value = conversion.toFixed(5);
}
</script>
</body>
</html>