JSFiddle - React, Tailwind, and code Playground
by Jayant Kumar
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<div class="uwrap" id="content">
<div class="upage vertical-col left panel" id="mainpage" data-header="none" data-footer="none">
<div class="table-thing with-label widget uib_w_1 d-margins" data-uib="app_framework/select" data-ver="1">
<label class="narrow-control label-inline">select from here</label>
<select class="wide-control" id="myclass">
<option value="ontrio" >onterio</option>
<option value="EL" selected >EL</option>
<option value="ON">ON</option>
</select>
<label>Enter taxable income:</label>
<input type="text" id="income" />
<input type="button" value="Calculate" name="calculate" id="calculate" /><br><br>
<label>Income tax owed:</label>
<input type="text" id="tax">
</div>
</div>
</div>
JavaScript
$(document).on('click', '#calculate', function() {
var province = $('#myclass').val();
var income = parseFloat($('#income').val());
var tax = 0;
switch(province)
{
case 'ontrio':
tax = calOntarioTax(income);
break;
case 'EL':
tax = calELTax(income);
break;
case 'ON':
tax = calONTax(income);
break;
}
$('#tax').val(tax);
});
function calOntarioTax(income)
{
var tempAmount = 0;
if((income > 0)&& (income < 40,922))
{
tempAmount = income * 5.05 / 100;
}
else if((income > 40,925)&& (income < 68,153))
{
tempAmount = income * 9.15 / 100;
}
else if((income > 68,153)&& (income < 70,000))
{
tempAmount = income * 11.16 / 100;
}
else if((income > 70,000)&& (income < 220,000))
{
tempAmount = income * 22 / 100;
}
else if(income >= 220,000)
{
tempAmount = income * 13.16 / 100;
}
else
{
tempAmount = income * .10;
}
tax = tempAmount + (income * .153);
return tax;
}
function calELTax(income)
{
var tempAmount = 0;
if((income > 0)&& (income < 40,922))
{
tempAmount = income * 2.05 / 100;
}
else if((income > 40,925)&& (income < 68,153))
{
tempAmount = income * 19.15 / 100;
}
else if((income > 68,153)&& (income < 70,000))
{
tempAmount = income * 13.16 / 100;
}
else if((income > 70,000)&& (income < 220,000))
{
tempAmount = income * 22 / 100;
}
else if(income...