Skip to content

Instantly share code, notes, and snippets.

@armanhakimsagar
Created November 15, 2018 16:00
Show Gist options
  • Select an option

  • Save armanhakimsagar/3f74027bf27b6d0cf7e84a6e323bf45b to your computer and use it in GitHub Desktop.

Select an option

Save armanhakimsagar/3f74027bf27b6d0cf7e84a6e323bf45b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<body>
Price :
<input id="price" oninput="priceSet()" type="text"><br><br>
Dis : <input id="dis" type="text" oninput="disSet()"><br><br>
Vat : <input id="vat" type="text" oninput="vatSet()"><br><br>
Net Price : <input id="netprice" type="text">
<script>
function priceSet() {
var price = document.getElementById('price').value;
document.getElementById("netprice").value = price;
}
function disSet() {
var dis = document.getElementById('dis').value;
var price = document.getElementById('price').value;
document.getElementById("netprice").value = price - price*dis/100;
}
function vatSet() {
var dis = document.getElementById('dis').value;
var price = document.getElementById('price').value;
var vat = document.getElementById('vat').value;
disprice = price - price*dis/100;
current_vat = disprice*vat/100;
vatprice = current_vat + disprice;
document.getElementById("netprice").value = vatprice;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment