Code:
function displayTotal(){
var adult = document.getElementById('adult').value == "" ? 0 : parseFloat(document.getElementById('adult').value) ;
if(isNaN(adult)) { adult = 0; }
... // use the above as a template for the rest
var total = parseFloat(adult + child + senior + military + seniorday + studentday);
alert("The total is " + total);
}
I did not pay attention to the IDs and whatnot that Philip M did. But JS _is_ case sensitive, so getElement
byId won't work, it has to be getElement
ById.