MeantimeSteve
Programmer
I am trying to run a function that will change a currency symbol on a page depending on a variable value. I am failry new to javascript as my main language is PHP so be kind when you take apart my code!
Here is what i have tried to date:
<script>
function showSymbol(currentCurrencyUsed) {
if(currentCurrencyUsed == "POUND") {
Symbol = "£";
document.test.currency.value = "POUND";
}
else {
Symbol = "€";
document.test.currency.value = "EURO";
}
return Symbol;
}
</script>
<body>
<form name="test">
<br>
<input type="text" name="currency" value="POUND"><br>
<script>
showSymbol(document.test.currency.value);
document.write(Symbol);
</script> <br>
<input type="button" value="Click Me" onClick="showSymbol(document.test.currency.value);">
</form>
</body>
</html>
Please can someone show me where i have gone wrong
Thanks in advance.
Here is what i have tried to date:
<script>
function showSymbol(currentCurrencyUsed) {
if(currentCurrencyUsed == "POUND") {
Symbol = "£";
document.test.currency.value = "POUND";
}
else {
Symbol = "€";
document.test.currency.value = "EURO";
}
return Symbol;
}
</script>
<body>
<form name="test">
<br>
<input type="text" name="currency" value="POUND"><br>
<script>
showSymbol(document.test.currency.value);
document.write(Symbol);
</script> <br>
<input type="button" value="Click Me" onClick="showSymbol(document.test.currency.value);">
</form>
</body>
</html>
Please can someone show me where i have gone wrong
Thanks in advance.