You need to declare a variable and set it to 0 at the start, then add to it if a button is checked. If the variable still == 0, no buttons have been checked.
Code:
function calculateCost() {
var totalChkd = 0;
for (var i = 1; i < 7; i++) {
var radiobutton = document.getElementById("flight" + i);
if (radiobutton.checked == true) {
var base=radiobutton.value; totalChkd++;
}
}
var rtn=document.getElementById("returnfare").checked?2:1;
for (var a = 1; a < 4; a++) {
var radiobutton = document.getElementById("seating" + a);
if (radiobutton.checked == true) {
var seatclass=radiobutton.value; totalChkd++;
}
}
if(totalChkd < 2){
alert("Please select both flight and seat"); return false;
}
var cost=base*rtn*seatclass;
alert("The selected flight will cost $" + cost);
}
Then change your submit button:
Code:
<input type="submit" value="Calculate" onClick="return calculateCost();">