PDA

View Full Version : Currency Convertion



casimirrex
10-20-2005, 08:46 AM
Hi
In ASP, Have any idea on Currency converstion using with JavaScript?.
Can you bear a hand to me?
thanking you
regards
rex

wkenny
10-23-2005, 12:32 PM
<table cellpadding=2 style="border:2px outset;background-color:silver;font-size:12px">

<tr><td class="default_style">Local Currency<br />Amount</td>
<td><input id="curamount" name="curamount " type=text value=100000 size=8></td></tr>

<tr><td class="plain_text">Exchange Rate </td>

<td><input id="exrate" name="exrate" type=text value=1.49 size=8></td></tr>

<tr> <td></td><td>
<button

onclick="getEuros(document.getElementById('curamount').value,document.getElementById('exrate').value)">Calculate</button></td></tr>

<tr>
<td colspan=2 align="right">Euro Amount</td></tr>

<tr><td></td><td><input type=text id="euros" name="euros" size=8></td></tr>
</table>


<script type="text/javascript">
<!--
function getEuros(camount,xrate) {

if (camount<=0 || xrate<=0 )
{
alert ("The fields must contain positive numbers!");
return 0;
}
if (NotNumeric(camount) || NotNumeric(xrate))
{alert("Fields can only contain numbers");
return 0;}



var acc=0;

acc = Math.round(camount*xrate*100)/100;

document.getElementById('euros').value=acc;

return camount;
}
function NotNumeric(ss){

var charpos = ss.search("[^0-9]");
if(ss.length > 0 && charpos == 0){return true;}
return false;
}
//-->
</script>

Hope this helps

hazeline03
07-17-2010, 08:00 AM
I know that Javascript can not read contents of a file. I can't think of an elegant JavaScript solution, apart from using frames. Maybe an expert will have to help you here.