Thank u for u quick reply.
I changed the value of the variable totalEstimate and assigned it a value of 5 as : var totlaEstimate = 5;
Now, if, lets say, I type 1 in the textbox.. I got a result of of 70?
Please, if possible, explain to me the whole process/calculations that are taking place and how?
Yes, you will get 70 as the result. Because:
Let's say, you declare:
totalEstimate = 5
Then you type 1 as the value in the text box name = numGuests
After that it will call the function calcGuests() as you have onchange="calcGuests()" in the text box
In the function, it does:
totalEstimate -= guestsCost means totalEstimate = 5-0; totalEstimate now = 5
guestsCost = document.details.numGuests.value 65 means guestsCost = 165; guestsCost now = 65
totalEstimate += guestsCost means totalEstimate = 5+65; totalEstimate now = 70
document.estimate.cost.value = "$" + totalEstimate means it puts value $70 to the text box named "cost"
That's all. Hope this can help.