EDIT: MADE A NEW FUNCTION WITH IF... still doesnt return -.-. I dont understand why.
I am trying to return results of calculating the taxes, total and total + taxes in this function. I want the results to be printed in h3 like the following:
function taxesrepas(option){
var soustot;
var taxes;
var total;
var soustot;
if (option = getelementbyid("spaghetti"))
total += 9.62;
taxes += 0.67;
soustot +=8.95;
if (option = getelementbyid("lasagne"))
total += 10.70;
taxes += 0.75;
soustot += 9.95;
if (option = getelementbyid("salade"))
total += 6.30;
taxes += 0.45;
soustot += 5.95;
if (option =getelementbyid("escargot"))
total += 5.32;
taxes += 0.37;
soustot += 4.95;
document.getElementById("taxes").innerHTML = taxes;
document.getElementbyid("total").innerHTML = total;
document.getElementbyid("soustot").innerHTML = soustot;
}
<h3 id="choix"></h3>
<h3 id="taxes" onclick= "taxesrepas(this.value)">taxes:</h3>
<h3 id="soustotal" onclick= "taxesrepas(this.value)">Sous-total:</h3>
<h3 id="total"onclick= "taxesrepas(this.value)">Total:</h3>
See Question&Answers more detail:os