1

<!DOCTYPE html>
<html>
<body>
Please enter a number:<BR>
<input type="text" id="amount_input">
<button onclick="other_amount_input()">Submit</button>
<script>
var balance=502.73;
function other_amount_input() {
    var input = document.getElementById("amount_input").value;
    var new_total = parseInt(input) + balance;
    alert("The amount deposited is: $" + input + ".00\n" + "This is the old balance: $" + balance + "\n" + "The new total is : $" + new_total);
}
</script>
</body>
</html>

I am trying to make an input box with html and javascript that takes an input (a positive number, can be a decimal but only to the hundredth place) I have the web page working to where it will take a whole number and add it to a hard coded number and display the output which is "hard_coded_number + input_number = output_number"

1
  • What is your question? When you work out what it is, perhaps post the code as a runnable snippet? Commented Dec 6, 2016 at 4:45

1 Answer 1

1

all I had to do was change parseInt to parseFloat and it worked for me

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.