In the below program i am using 3 if conditions, but the if statement in the middle doesn't works and last if statement works fine,when I change third if statement to second statement again second statement is not working properly. Third if statement works fine
function calculate() {
var quantity = document.getElementById("quantity").value;
var price = document.getElementById("price").value;
var discount = document.getElementById("discount").value;
var tax = document.getElementById("tax").value;
if((quantity && price ) != null) {
amount = quantity * price;
document.getElementById("amount").value = amount;
} else {
alert("price & tax required");
}
if(discount != null) {
var discount_amount = (quantity*price*discount)/100;
amount = (quantity*price) - discount_amount;
document.getElementById("amount").value = amount;
} else {
document.getElementById("amount").value = quantity * price;
}
if(tax != null) {
var tax_amount = (quantity*price*tax)/100;
amount = (quantity*price) + tax_amount;
document.getElementById("amount").value = amount;
} else {
document.getElementById("amount").value = quantity * price;
}
}