I'm trying to get a calculated total from getting the values from these drop boxes and running them through a function with preset values but it doesn't return anything. The alert box doesn't pop up either, could anyone tell me exactly what's wrong here?
Here is my code snippet:
<!DOCTYPE html>
<html>
<head>
<script>
function calcTotal(){
var numAdult = parseInt(document.getElementById('adultStandard').value);
var numConcession = parseInt(document.getElementById('concessionStandard').value);
var numChild = parseInt(document.getElementById('childStandard').value);
var adultStandard = 10.10;
var concessionStandard = 11.50;
var childStandard = 12.70;
var saleTotal = (adultStandard * numAdult) + (concessionStandard * numConcession) + (childStandard * numChild);
document.getElementById('totalCost').innerHTML = "test";
return true;
alert("Total is: " saleTotal);
}
</script>
</head>
<body>
<form action onchange='return calcTotal()' method='post'>
Adult:
<select id='adultStandard' name='adultStandard'>
<script>
var maxqty = 10;
for ( var i=0; i<=maxqty; i++ )
document.write('<option value="'+i+'">'+i+'</option>');
</script>
</select>
<br>
Concession:
<select id='concessionStandard' name='concessionStandard'>
<script>
var maxqty = 10;
for ( var i=0; i<=maxqty; i++ )
document.write('<option value="'+i+'">'+i+'</option>');
</script>
</select>
<br>
Child:
<select id='childStandard' name='childStandard'>
<script>
var maxqty = 10;
for ( var i=0; i<=maxqty; i++ )
document.write('<option value="'+i+'">'+i+'</option>');
</script>
</select>
<br>
<label>
Total: $<input id='totalCost' readonly='readonly' value='0'>
</label>
</form>
</body>
</html>