1

I am making a simple daily sales and expense report sheet to store on my server with inputed information. The problem I am having is the output, or the result uses the two decimal places, but it multiplies from the inputed information but from the whole number, and ignores the decimal places.

So the equation is supposed to sales * 12% = result, but if I put in $40 for sales, the result 4.80 (correct) if I put in $39 for sales, the result 4.68 (correct) if I put in $39.95 for sales, the result is 4.68 (incorrect) when it should be 4.79

so here is what I am working with

    var ppc = parseInt(document.form.ppc.value);

    var result=ppc * 0.12;
    document.form.prof1.value=result.toFixed(2);

If I am doing this in a stupid way, its cause Im new to js and jq and dont quite understand it, feel free to correct me for the right way to do this

1 Answer 1

2

You need to use parseFloat instead of parseInt. Last one returns 39 for 39.95$ instead of 39.95.

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.