gpt4 book ai didi

JavaScript 转换不起作用

转载 作者:行者123 更新时间:2023-12-03 08:37:51 25 4
gpt4 key购买 nike

当您点击 mBTC,然后尝试点击返回 BTC 时,它不起作用。然而,如果你去比特或坐,然后再回到比特币,那就没问题了。我不明白为什么它没有从 mBTC 转换为 BTC。也许与 ConvertMBTC 函数有关?

var SAT = 0.00000001;
var BIT = 0.000001;
var MBIT = 0.001;
var BTC = 1;
var currentUnit = BTC;

function changeColor(div) {
document.getElementById('satoshiBox').style.background = '#29b8ff';
document.getElementById('bitBox').style.background = '#29b8ff';
document.getElementById('BTCBox').style.background = '#29b8ff';
document.getElementById('mBTCBox').style.background = '#29b8ff';

document.getElementById(div).style.background = '#ed546a';
}

function satoshiConvert(input) {
if (currentUnit != SAT) {
input.value = (convertBTC(input.value) / SAT).toFixed(0);
currentUnit = SAT;
changeColor('satoshiBox');
btcConvert(input);
}
}

function bitConvert(input) {
if (currentUnit != BIT) {
input.value = (convertBTC(input.value) / BIT).toFixed(2);
currentUnit = BIT;
changeColor('bitBox');
btcConvert(input);
}
}

function mBTCConvert(input) {
if (currentUnit != MBIT) {
input.value = (convertBTC(input.value) / MBIT).toFixed(4);
currentUnit = MBIT;
changeColor('mBTCBox');
btcConvert(input);
}
}

function bitcoinConversion(input) {
if (currentUnit != MBIT) {
input.value = (convertBTC(input.value) / BTC).toFixed(8);
currentUnit = BTC;
changeColor('BTCBox');
btcConvert(input);
}
}

<div class="bitcoin">
<div class="rateboxy">
<input value="1" type="text" name="btc" id="btc" class="rate" onchange="btcConvert(this);" onkeyup="btcConvert(this);" />
</div>
</div>
<div class="unitBox">
<div class="smallUnitBox" onclick="satoshiConvert(btc);" id="satoshiBox">sat</div>
<div class="smallUnitBox" onclick="bitConvert(btc);" id="bitBox">bit</div>
<div class="smallUnitBox" onclick="mBTCConvert(btc);" id="mBTCBox">mBTC</div>
<div class="smallUnitBox2" onclick="bitcoinConversion(btc);" id="BTCBox">BTC</div>
</div>
<p id="equals">=</p>
<div class="rateboxy">
<input value="<?php echo $bitcoinPrice; ?>" type="text" name="cur" id="cur" class="rate" onchange="usdConvert(this);" onkeyup="usdConvert(this);" />
</div>
</div>
</center>

最佳答案

bitcoinConversion() 的开头,您有:

if (currentUnit != MBIT)

因此,如果您上次点击mBTC,它不会执行任何操作。该行应该是:

if (currentUnit != BTC)

关于JavaScript 转换不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33139811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com