I have a webpage that is working with the following
1. total coins (Working)
2. latest usd value for coins like BTC SHIB eg. ( Not working, must add it manually every time)
3 total in usd (Working)
4. total in ZAR (Working)
I need tp let number 2 get the info from somewhere , but does not know how to do it in html.
Here are my code I have for now
CODE
<td><font color="#eae0c8"><b><label for="firstNum2">BTC</label></b></FONT></td>
<td><input style="color: #17202A; font-family: Comic Sans MS; font-weight: bold; font-size: 12px; background-color: #EBDEF0; type="number2" id="firstNum2" name="firstNum2"></td>
<td><font color="#BCC6CC"><b><label for="secondNum2">0.00047536</label></b></font></td>
<input style="visibility:hidden"; type="number2" id="secondNum2" name="secondNum2">
<td><button type="button" onclick="multiply5()">Multiply</button></td>
<td><input style="color: #17202A; font-family: Comic Sans MS; font-weight: bold; font-size: 12px; background-color: #E8F8F5; type="text" id="result5" name="result5"/></td>
<input style="visibility:collapse" readonly="readonly" type="usdzar2" id="usd2" name="usd2">
<font style="visibility:collapse" 1color="#BCC6CC"><b><label for="zar2"></label></b></font>
<input style="visibility:collapse" type="usdzar2" id="gcw_valFnAj0a2vV1" name="zar2">
<td><button type="button" onclick="multiply6()">Multiply</button></td>
<td><input style="color: #17202A; font-family: Comic Sans MS; font-weight: bold; font-size: 12px; background-color: #E8F8F5; type="text" id="result6" name="result6"/></td>
CODE
<script>
function multiply5(){
var num9 = document.getElementById("firstNum2").value;
document.getElementById("secondNum2").value = 0.00047536;
var num10 = document.getElementById("secondNum2").value;
var result5 = num9 * num10;
document.getElementById("result5").value = result5.toLocaleString('en-US',{ maximumFractionDigits: 8 });
document.getElementById("result5").style.color = "red";
document.getElementById("result5").style.fontWeight = "900";
}
</script>
<script>
function multiply6(){
var num11= document.getElementById("result5").value.replace(/,/g,''); //remove any commas
var num12 = document.getElementById("gcw_valFnAj0a2vV1").value;
var result6 = num11 * num12;
document.getElementById("result6").value = result6.toLocaleString('en-US',{ maximumFractionDigits: 8 });
document.getElementById("result6").style.color = "red";
document.getElementById("result6").style.fontWeight = "900";
}
</script>
I have found this on how to, but how do I add it to my code
CODE
<script src="lib/script.js"></script>
the script
CODE
const api = 'https://apiv2.bitcoinaverage.com/indices/local/ticker/short?crypto=BTC&fiat=USD'
$.get(api, p => {
document.querySelector('pre').textContent = JSON.stringify(p, null, 2)
});