Aaron Saray

open source programmer,
web developer

entrepreneur, author
and musician

My Blog

contains PHP, Web and business/entrepreneurial related content. Please join in the conversation!

Figuring out Price Before Tax

A lot of the time I give quotes including taxes. Every once in a while, someone is curious about what the tax is on a service.

I was messing around the other day and came up with this Javascript function. It takes in the total amount, the tax in percent, and returns the cost before tax.

?View Code JAVASCRIPT
1
2
3
4
    function figureBeforeTax(amount, tax)
    {
        return Math.round((amount)*(100 / (100 + ((tax/100)*100)))*100)/100;
    }

This entry was posted in javascript and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>