XLR3
07-28-2008, 02:32 PM
Currently I'm working on a currency calculator to perform the calculation of converting American to Euro and Euro to American. My biggest issue is how to get the If statements to work with Javascript. Currently this is my code:
<FORM NAME="cform">
<Input type = radio Name = r1 Value = "American">American
<Input type = radio Name = r1 Value = "Euro">Euro
</FORM>
<head>
<title>Money Exchange</title>
<script language="JavaScript">
<!--
function convert() {
var amt = parseFloat(exchange.amount.value);
var euro = Math.round((amt * .7) * 100) / 100;
document.write(exchange.amount.value + " dollars is " + euro + " Euros");
}
{
var amt = parseFloat(exchange.amount.value);
var american = Math.round((amt * 1.568) * 100) / 100;
document.write(exchange.amount.value + " euros is " + american + " Dollars ");
//-->
</script>
</head>
<body>
<form name="exchange" action="javascript:convert()" method="post">
Amount
<input type="text" name="amount"><br/>
<input type="submit" value="Submit Form">
</form>
I have been Googling many tutorials but I'm still not sure where to begin. Any helps or tips would be appreciated. Thank you.
<FORM NAME="cform">
<Input type = radio Name = r1 Value = "American">American
<Input type = radio Name = r1 Value = "Euro">Euro
</FORM>
<head>
<title>Money Exchange</title>
<script language="JavaScript">
<!--
function convert() {
var amt = parseFloat(exchange.amount.value);
var euro = Math.round((amt * .7) * 100) / 100;
document.write(exchange.amount.value + " dollars is " + euro + " Euros");
}
{
var amt = parseFloat(exchange.amount.value);
var american = Math.round((amt * 1.568) * 100) / 100;
document.write(exchange.amount.value + " euros is " + american + " Dollars ");
//-->
</script>
</head>
<body>
<form name="exchange" action="javascript:convert()" method="post">
Amount
<input type="text" name="amount"><br/>
<input type="submit" value="Submit Form">
</form>
I have been Googling many tutorials but I'm still not sure where to begin. Any helps or tips would be appreciated. Thank you.