[英]my currency converter question is i a need function to convert rand(ZAR) to pound, dollar, and euro
I need to put in a certain amount of rands and get back euro, pound, and dollar.我需要投入一定数量的兰特才能取回欧元、英镑和美元。
The rest of my code does have the link to the javascript file.我的其余代码确实具有指向 javascript 文件的链接。 I've only put the dollar() function in for now because I was at least trying to get one to work but it didn't so I need help.
我现在只放了美元()函数,因为我至少试图让一个工作,但它没有,所以我需要帮助。
function dollar() { let money = document.getElementbyId("rand").value; const $ = 15.5734; document.getElementById('result').innerHTML = $ * money; }
<form> Rand: <input type="number" id="rand"> <input id="dollar" type="button" onclick="dollar()" value="dollar"/> <input id="euro" type="button" onclick="euro()" value="euro"> <input id ="pound" type="button" onclick="pound()" value="pound"> </form> <p> result is: <span id="result"></span> </p>
You just needed to change function name and change document.getElementbyId
to document.getElementById
您只需更改函数名称并将
document.getElementbyId
更改为document.getElementById
<form> Rand: <input type="number" id="rand"> <input id="dollar" type="button" onclick="todollar()" value="dollar"/> <input id="euro" type="button" onclick="euro()" value="euro"> <input id ="pound" type="button" onclick="pound()" value="pound"> </form> <p> result is: <span id="result"></span> </p> <script> function todollar() { let money = document.getElementById("rand").value; const $ = 15.5734; document.getElementById('result').innerHTML = $ * money; } </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.