I need to create a function with 2 arguments (price1, price2), which should be added together and the result would be displayed in a text field after adding Vat to them.
Overall, I need to have 3 text fields: price1, price2 and results. In addition, the results field should be calculated after pushing the button calculate.
So far, I've come up with a return function with document.write, but it obviously doesn't display any text fields, which looks like that:
function getTotalPrice(price1,price2,Vat)
{
var sum=price1+priceb;
var Vat=20;
return ((sum*Vat)*100)/100;
}
document.write(getTotalPrice(4,3));
I have no clue how to create the button that could calculate Vat and display it in the third text box.
Vatvariable in the function parameters?Vatwas redeclared inside the function, as it will then never take on any value except 20.