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. 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>
CodePudding user response:
You just needed to change function name and change document.getElementbyId
to 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>