私は簡単なコンバータを動作させようとしています。現時点では入力フィールドは動作しません。 私はPHPのように価格変数を取得できますか?シンプルなJavaScriptユニティコンバータが動作しない
<h1 style='font-size:46px'>1 DOLLAR = <p id="currentprice" type="number"><?php $url = "https://api.fixer.io/latest?base=USD"; $json = file_get_contents($url); $json_data = json_decode($json, true); $price = $json_data["rates"]["BRL"]; echo $price; ?></p></h1>
How many Dollars?
<input oninput='finalAmountUSD()' onchange='finalAmountUSD()' style='font-size:23px;height:45px' type='number' class="buy buyinput form-control" id='usdamount' required value='0.00000000' tabindex="1" />
How many BRL?
<input oninput='finalAmountBRL()' onchange='finalAmountBRL()' style='font-size:23px;height:45px' type='number' class="buy buyinput form-control" id='brlamount' required value='0.00' tabindex="2" />
<script>
function finalAmountUSD()
{
x = document.getElementById('currentprice').value;
y = document.getElementById('usdamount').value;
z = document.getElementById('brlamount').value;
document.getElementById('usdamount').value = x * z;
}
function finalAmountBRL()
{
x = document.getElementById('currentprice').value;
y = document.getElementById('usdamount').value;
z = document.getElementById('brlamount').value;
document.getElementById('brlamount').value = x * y;
}
</script>
ここで 'atm'とは何ですか? –
@manikantgautam - https://www.acronymfinder.com/ATM.html - At The Moment – Quentin
バリューx = document.getElementById( "currentprice")。値の代わりにinnerHTMLを試してください。 –