I am creating a online estimator with vanilla js, now at the end i want to calculate after the total cost i want to add 10% on top that. How would I add the 10% in the total bill amount with JS?
Now how would I get the total bill amount which includes GST as well.
Please help me with this, I’ll be really thankful.
Thanks and Regards in Advance
Here is my code
var product_total = document.getElementById('product_total');
var call_cost = document.getElementById('call_cost');
var gst = document.getElementById('tax') / 100;
// Decrease Number //
const decreaseNumber = (incdec,itemprice) => {
var itemval = document.getElementById(incdec);
var itemprice = document.getElementById(itemprice);
console.log(itemval.value);
if(itemval.value <= 0){
itemval.value = 0;
alert('Negative Quantity Not Allowed. Please Select Atleast One Service');
}
else{
itemval.value = parseInt(itemval.value) - 1;
itemval.style.background = '#fff';
itemval.style.color = '#000';
itemprice.innerHTML = parseInt(itemprice.innerHTML) - 70;
product_total.innerHTML = parseInt(product_total.innerHTML) - 70;
net_amount.innerHTML = parseInt(product_total.innerHTML) + parseInt(call_cost.innerHTML);
document.getElementById("net_amount_total").value= parseInt(product_total.innerHTML) + parseInt(call_cost.innerHTML);
// document.getElementById("service_name").value
}
}
//Increase Number
const increaseNumber = (incdec,itemprice) => {
var itemval = document.getElementById(incdec);
var itemprice = document.getElementById(itemprice);
if(itemval.value >= 10){
itemval.value = 10;
alert('Maximum Number of Services Upto 10 Allowed');
itemval.style.background = 'red';
itemval.style.color = '#fff';
}
else{
itemval.value = parseInt(itemval.value) + 1;
itemprice.innerHTML = parseInt(itemprice.innerHTML) + 70;
product_total.innerHTML = parseInt(product_total.innerHTML) + 70;
net_amount.innerHTML = parseInt(product_total.innerHTML) + parseInt(gst.innerHTML) + parseInt(call_cost.innerHTML);
// net_amount.innerHTML = parseInt(gross_amount.innerHTML) / 10%;
document.getElementById("net_amount_total").value= parseInt(product_total.innerHTML) + parseInt(call_cost.innerHTML);
}
}
<div class="summery-list">
<div class="icon">
<img class="img-fluid" src="https://wefreelancer.in/love/ntcc/wp-content/themes/ntcc/images/bathroom-color-icon.png" alt="">
</div>
<div class="title">
<h4>GST</h4>
</div>
<div class="price">
<h4><span id="tax">10%</span></h4>
</div>
</div>