'Show price of crypto in my webpage every time I open it
I am battling with his, need help.
I want to show the price of a crypto token in my webpage, But struggle to figure it out Using coinmarketcap or Nomanics. This is what I have , see bold in my code, lost very lost with this
<script>
function multiply5(){
var num9 = document.getElementById("firstNum2").value;
document.getElementById("secondNum2").value = 0.00047536;
**document.getElementById("btcusd").value**;
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>
<td><b><label for="firstNum2">BTC</label></td>
**<td><input type="btcusd" id ="btcusd" name="btcusd"></td>**
<td><b><label for="secondNum2">0.00047536</label></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>
Solution 1:[1]
If I look at the bold statements in your markup, I can see that you've written id ="btcusd" when it probably should be id="btcusd" (without space before your equals sign).
I don't know if this is what causes your issues or not. It's hard to know what errors you are getting since in your example it seems to be plain syntax errors when trying to run your code snippet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hackerbyday |
