By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

How to calculate tax in html table?

P: 4
I have the following table:

Expand|Select|Wrap|Line Numbers
  1.       0 -  40 000    0%       0
  2.  40 001 -  80 000   27%       0
  3.  80 001 - 200 000   32%  10 800
  4. 200 001 - 750 000   34%  49 200
  5. 750 001 -           37% 236 200
Assuming my Taxable Salary is 155 123.00 p.a, How do I calculate my tax payable with java script.(IF/Match). I all ready have written the table in html to sum all the income and deductions which gives me 155 123.00.

Thank you
May 22 '12 #1
Share this Question
Share on Google+
7 Replies


Rabbit
Expert Mod 10K+
P: 12,430
What code do you have so far?
May 22 '12 #2

P: 4
In Javascript!!! Hope I am right. Quite new to this stuff!!!


Expand|Select|Wrap|Line Numbers
  1. html>
  2. <head>
  3. <title>MONTHLY TAX</title>
  4. <style>
  5.      body {
  6.      font-size : sans-serif ;
  7.      }
  8.      #summation {
  9.      font-size : 18px ;
  10.      font-weight : bold ;
  11.      color : black ;
  12.      }
  13.      .txt {
  14.      background-color : gold ;
  15.      font-weight : bold ;
  16.      text-align : right ;
  17.      }
  18. </style>
  19. <script type="text/javascript"><!--
  20. function updatesum () {
  21. document.form.sum.value= (document.form.sum1.value -0) +
  22. (document.form.sum2.value -0) +
  23. (document.form.sum3.value -0) +
  24. (document.form.sum4.value -0) +
  25. (document.form.sum5.value -0) +
  26. (document.form.sum6.value -0) -
  27. (document.form.sum7.value -0) ;
  28. }
  29. function multiply () {
  30. var ans= (document.form.sum.value) * (document.form.twelve.value)
  31. document.form.answer.value=ans;
  32. }
  33. //--></script>
  34. </head>
  35. <body>
  36. <form name="form">
  37. <table width="335" bgcolor="black">
  38.    <caption align="left">
  39.    <b>NAMIBIA PERSONAL INCOME TAX RATES</b>
  40.    </caption>
  41.    <tr bgcolor="#EDC112">
  42.       <td align="right">0</td>
  43.       <td align="right">40 000</td>
  44.       <td align="right">0%</td>
  45.       <td align="right">0</td>
  46.    </tr>
  47.    <tr bgcolor="#EDC112">
  48.       <td align="right">40 001</td>
  49.       <td align="right">80 000</td>
  50.       <td align="right">27%</td>
  51.       <td align="right">0</td>
  52.    </tr>
  53.    <tr bgcolor="#EDC112">
  54.       <td align="right">80 001</td>
  55.       <td align="right">200 000</td>
  56.       <td align="right">32%</td>
  57.       <td align="right">10 800</td>
  58.    </tr>
  59.    <tr bgcolor="#EDC112">
  60.       <td align="right">200 001</td>
  61.       <td align="right">750 000</td>
  62.       <td align="right">34%</td>
  63.       <td align="right">49 200</td>
  64.    </tr>
  65.    <tr bgcolor="#EDC112">
  66.       <td align="right">750 001</td>
  67.       <td>&nbsp;</td>
  68.       <td align="right">37%</td>
  69.       <td align="right">236 200</td>
  70.    </tr>
  71.    <tr bgcolor="#EDC112">
  72.       <td><b><u>Monthly Tax</u></b></td>
  73.       <td>&nbsp;</td>
  74.       <td>&nbsp;</td>
  75.       <td>&nbsp;</td>
  76.    </tr>
  77.    <tr bgcolor="#EDC112">
  78.       <td>Basic Pay</td>
  79.       <td dir="rtl"><input name="sum1" id="sum1" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  80.       <td>&nbsp;</td>
  81.       <td>&nbsp;</td>
  82.    </tr>
  83.    <tr bgcolor="#EDC112">
  84.       <td>Bonus</td>
  85.       <td dir="rtl"><input name="sum2" id="sum2" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  86.       <td>&nbsp;</td>
  87.       <td>&nbsp;</td>
  88.    </tr>
  89.    <tr bgcolor="#EDC112">
  90.       <td>Overtime</td>
  91.       <td dir="rtl"><input name="sum3" id="sum3" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  92.       <td>&nbsp;</td>
  93.       <td>&nbsp;</td>
  94.    </tr>
  95.    <tr bgcolor="#EDC112">
  96.       <td>Standby</td>
  97.       <td dir="rtl"><input name="sum4" id="sum4" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  98.       <td>&nbsp;</td>
  99.       <td>&nbsp;</td>
  100.    </tr>
  101.    <tr bgcolor="#EDC112">
  102.       <td>2/3 Housing All</td>
  103.       <td dir="rtl"><input name="sum5" id="sum5" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  104.       <td>&nbsp;</td>
  105.       <td>&nbsp;</td>
  106.    </tr>
  107.    <tr bgcolor="#EDC112">
  108.       <td>Other Income</td>
  109.       <td dir="rtl"><input name="sum6" id="sum6" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  110.       <td>&nbsp;</td>
  111.       <td>&nbsp;</td>
  112.    </tr>
  113.    <tr bgcolor="red">
  114.       <td bgcolor="red">Less:Pension</td>
  115.       <td dir="rtl"><input name="sum7" id="sum7" type="text" size="12" maxlength="12" onchange="updatesum()"></td>
  116.       <td>&nbsp;</td>
  117.       <td>&nbsp;</td>
  118.    </tr>
  119.    <tr bgcolor="#EDC112">
  120.       <td><b>Taxable Salary</b></td>
  121.       <td dir="rtl"><input name="sum" id="sum" type="text" size="14" maxlength="14" readonly="true" disabled="disabled"></td>
  122.       <td></td></td>
  123.       <td></td></td>
  124.    </tr>
  125.    <tr bgcolor="#EDC112">
  126.       <td><input name="twelve" id="twelve" type="button" disabled="true" value="12"></td>
  127.       <td dir="rtl"><input name="answer" id="answer" type="text" size="14" maxlength="14"></td>
  128.       <td></td>
  129.       <td><input name="now" id="now" type="button" value="answer" onclick="multiply()" maxlength="14" size="14"></td>
  130.    </tr>
  131.    <tr bgcolor="#EDC112">
  132.       <td></td>
  133.       <td>&nbsp;</td>
  134.       <td>&nbsp;</td>
  135.       <td>&nbsp;</td>
  136.    </tr>
  137.    <tr bgcolor="#EDC112">
  138.       <td><b>Tax Payable</b></td>
  139.       <td dir="rtl"><input name="Tax Payable" id="Tax Payable" type="text" size="12" maxlength="12" readonly="true"></td>
  140.       <td></td>
  141.       <td></td>
  142.    </tr>
  143.    <tr bgcolor="#EDC112">
  144.       <td>1</td>
  145.       <td>&nbsp;</td>
  146.       <td>&nbsp;</td>
  147.       <td>&nbsp;</td>
  148.    </tr>
  149.    <tr bgcolor="#EDC112">
  150.       <td>2</td>
  151.       <td>&nbsp;</td>
  152.       <td>&nbsp;</td>
  153.       <td>&nbsp;</td>
  154.    </tr>
  155.    <tr bgcolor="#EDC112">
  156.       <td>3</td>
  157.       <td>&nbsp;</td>
  158.       <td>&nbsp;</td>
  159.       <td>&nbsp;</td>
  160.    </tr>
  161.    <tr bgcolor="#EDC112">
  162.       <td>4</td>
  163.       <td>&nbsp;</td>
  164.       <td>&nbsp;</td>
  165.       <td>&nbsp;</td>
  166.    </tr>
  167.    <tr bgcolor="#EDC112">
  168.       <td>5</td>
  169.       <td>&nbsp;</td>
  170.       <td>&nbsp;</td>
  171.       <td>&nbsp;</td>
  172.    </tr>
  173.    <tr bgcolor="#EDC112">
  174.       <td>6</td>
  175.       <td>&nbsp;</td>
  176.       <td>&nbsp;</td>
  177.       <td>&nbsp;</td>
  178.    </tr>
  179.    <tr bgcolor="#EDC112">
  180.       <td>&nbsp;</td>
  181.       <td>&nbsp;</td>
  182.       <td>&nbsp;</td>
  183.       <td>&nbsp;</td>
  184.    </tr>
  185.    <tr bgcolor="#EDC112">
  186.       <td>&nbsp;</td>
  187.       <td>&nbsp;</td>
  188.       <td>&nbsp;</td>
  189.       <td>&nbsp;</td>
  190.    </tr>
  191.    <tr bgcolor="#EDC112">
  192.       <td>&nbsp;</td>
  193.       <td>&nbsp;</td>
  194.       <td>&nbsp;</td>
  195.       <td>&nbsp;</td></td>
  196.    </tr>
  197. </table>
  198. <form/>
  199. </body>
  200. </html>
May 23 '12 #3

Rabbit
Expert Mod 10K+
P: 12,430
Please use code tags when posting code.

And is it working?
May 23 '12 #4

P: 4
Yes Rabbit,it is working. Where can I mail you the html page?
May 24 '12 #5

Rabbit
Expert Mod 10K+
P: 12,430
Well, if it's working, I don't need to see the page.
May 24 '12 #6

P: 4
Hi Rabbit,

Did you fully understand my question? I am missing the final part in my table,i.e." How will I match the 155 123.00(Taxable Salary) in the table to calculate the Tax Payable? with reference to the Table"
May 24 '12 #7

Rabbit
Expert Mod 10K+
P: 12,430
Whether or not I understood your question is moot. You said it was working. Meaning you were able to resolve your own question. However, it seems that you mean what you have so far runs fine but your code is not working because it's not producing the results you want.

I will have to look at this tomorrow when I get more time.
May 24 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.