TDR金额的字段" 服务税(12.36%):"没有在表格中工作。
这应该自动从TDR金额计算ST金额(12.36%)并显示它,然后将其添加到总计最后
HTML
<form id="calculator" method="post">
<table class="tbl_insert">
<tr>
<th>
<label for="amount">Amount:</label>
</th>
<td>
<input type="text" name="amount" id="amount" value="" class="field" />
</td>
</tr>
<tr>
<th>
<label for="tax">Card Type :</label>
</th>
<td>
<select name="tax" id="tax" class="select">
<option value="2.1">VISA</option>
<option value="2.1">MasterCard</option>
<option value="2.1">ICICI Bank</option>
<option value="2.1">Diners Club Card</option>
<option value="3.6">Amex Card</option>
<option value="2.1">other</option>
</select>
</td>
</tr>
<tr>
<th>
<label for="tax_amount">TDR Amount:</label>
</th>
<td>
<input type="text" name="tax_amount" id="tax_amount" value="0.00" class="field" disabled="disabled" />
</td>
</tr>
<tr>
<th>
<label for="tdrtax_amount">Service Tax (12.36%) on TDR Amount:</label>
</th>
<td>
<input type="text" name="tdrtax_amount" id="tdrtax_amount" value="0.00" class="field" disabled="disabled" />
</td>
</tr>
<tr>
<th>
<label for="total_amount">Grand Total:</label>
</th>
<td>
<input type="text" name="total_amount" id="total_amount" value="0.00" class="field" disabled="disabled" />
</td>
</tr>
</table>
</form>
JS
var calcObject = {
amountNull: '0.00',
amountTax: '0.00',
amountTDRTax: '0.00',
amountTotal: '0.00',
run: function () {
var amount = $('#amount').val();
var tax = $('#tax').val();
var included = $('#tax_included').is(':checked');
if (amount !== '' && tax !== '') {
if (included) {
var amountNew = amount / ((tax / 100) + 1);
calcObject.amountTax = parseFloat(amount) - parseFloat(amountNew);
calcObject.amountTDRTax = (amountTax * 12.36) / 100;
calcObject.amountTotal = amountNew.toFixed(2);
} else {
calcObject.amountTax = (amount * tax) / 100;
calcObject.amountTotal = parseFloat(amount) + parseFloat(calcObject.amountTax) + parseFloat(calcObject.amountTDRTax);
}
$('#tax_amount').val(parseFloat(calcObject.amountTax).toFixed(2));
$('#tdrtax_amount').val(parseFloat(calcObject.amountTDRTax).toFixed(2));
$('#total_amount').val(parseFloat(calcObject.amountTotal).toFixed(2));
} else {
$('#tax_amount').val(calcObject.amountNull);
$('#tdrtax_amount').val(calcObject.amountNull);
$('#total_amount').val(calcObject.amountNull);
}
}
};
$(function () {
$('#amount').keyup(function () {
calcObject.run();
});
$('#tax_included').click(function () {
calcObject.run();
});
$('#tax').change(function () {
calcObject.run();
});
$('#tdrtax_amount').change(function () {
calcObject.run();
});
});