banshee
03-18-2004, 02:12 PM
Hi all
My first post :-)
I am VERY new to javascript but managed to make this little bit of javascript work for me but now I am struggling:
<script language='JavaScript'>
<!--
function getEUTOUSD(price) {
document.write(price * 1.23);
}
// -->
</script>
I then call it in my page with this:
<script type="text/javascript"> getEUTOUSD('25.00');
</script>
As you can probably work out, this works out what the $ ammount would be from an inputted € amount.
The problem I have is that I require it to only show two numbers after the decimal like this 45.33 but in some instances it shows 45.33333333333331
I know I have to do it with math round but whatever I try does not work.
Also, the resulted figure it produces creates a space in front of it so when I put the € symbol in front of the result I get € 45.99 instead of €45.99
Any help would be greatly appreciated, I tend not to ask people to do the work for me and just ask when I have done as much as I can do, so I hope this is OK.
Thanks for your help in advance.
My first post :-)
I am VERY new to javascript but managed to make this little bit of javascript work for me but now I am struggling:
<script language='JavaScript'>
<!--
function getEUTOUSD(price) {
document.write(price * 1.23);
}
// -->
</script>
I then call it in my page with this:
<script type="text/javascript"> getEUTOUSD('25.00');
</script>
As you can probably work out, this works out what the $ ammount would be from an inputted € amount.
The problem I have is that I require it to only show two numbers after the decimal like this 45.33 but in some instances it shows 45.33333333333331
I know I have to do it with math round but whatever I try does not work.
Also, the resulted figure it produces creates a space in front of it so when I put the € symbol in front of the result I get € 45.99 instead of €45.99
Any help would be greatly appreciated, I tend not to ask people to do the work for me and just ask when I have done as much as I can do, so I hope this is OK.
Thanks for your help in advance.