recently started to study Javascript and having an issue with adding two variables together
function btn_click()
{
var money = parseInt(document.getElementById("money").value);
var dollar = parseInt(3.67 * money);
var xfer = parseInt(0);
var total = parseFloat(dollar + xfer);
var dollar = dollar.toFixed(2);
if (isNaN(money))
{
alert("Please enter a valid amount!");
}
else
{
if (money > 15000)
{
xfer = 0;
document.writeln("Amount in dirhams: " + dollar +" AED<br>");
document.writeln("Transfer charges: " + xfer +" AED<br>");
document.writeln("Total: <span style='font-weight:bold'>" +total+" AED<br>");
}
else
{
xfer = 25;
document.writeln("Amount in dirhams: " + dollar +" AED<br>");
document.writeln("Transfer charges: " + xfer +" AED<br>");
document.writeln("<span style='font-weight:bold'> Total: "+ total + " AED<br></span>");
}
}
}
basically, my last line in the "ELSE" sections
document.writeln("Total: <span style='font-weight:bold'>" +total+" AED<br>");
does not work, when I click on my button, everything gets calculated but the last line, the last line will only display my variable "dollar". Lets say for example I input 100 and clicked the button, my first line would be 367.00 AED and my second line would be 25 AED but my last line would say 367 AED, it did not sum the first two lines.
Sorry if I seem unclear, if you need more information i'd be happy to give it
Thank you guys