S
shannon
Hi
Can anyone tell me what i'm doing wrong.I'm asking the user to enter
their name and seat class either economy or first class. I want to
store than information in an array and print the passenger information
on the screen.
<html>
<head>
<title>Airline Booking</title>
<script type="text/javascript">
var myairline = new Array(10);
var first = 0;
var economy = 5;
var name;
var class;
<!-- Hide JavaScript from older browsers
//enter details
name=window.prompt("Please Enter your name");
class=window.prompt("Please Enter flight class. Enter 1 for first
class, 2 for second class");
//the following two if statements were put in instead of using a
function
if ( first == 4 && class == 1 ){
window.alert( "Do you want second class?" );
if (class == 2){
class=2;
}
}
if (economy == 9 && class == 2){
window.alert( "Do you want first class?" );
if (class == 1){
class=1;
}
}
//if the flight class is first class
if ( class = 1 ){
//this statement checks if the array is full (might need break
statement)
if (first == 4){
window.alert( "Next Plane leaves in 3 hours" );
}
//puts name into first class seat of array
array[first]=name;
//increments the index(also seat number) of the array and
prints out this new seatnumber, class and passenger name
first++;
document.write("Class: First Class, Passenger:+array[first]+<br
/>");
}
//if the flight class is economy class
if ( class = 2 ){
//this statement checks if the array is full (might need a
break statement to get out)
if (economy == 9){
window.alert( "Next Plane leaves in 3 hours" );
}
//puts name into economy seat of array
array[economy]=name;
//increments the index(also seat number) of the array and
prints out this new seat class and passenger name
first++;
document.write("Class: Economy Class,
Passenger:+array[first]+");
}
//print details
for (i=0;i<myairline.length;i++){
//flight details are output to the screen
document.write(myairline ++ "<br />")
}
// End hiding JavaScript from older browsers -->
</script>
</head>
</html>
Can anyone tell me what i'm doing wrong.I'm asking the user to enter
their name and seat class either economy or first class. I want to
store than information in an array and print the passenger information
on the screen.
<html>
<head>
<title>Airline Booking</title>
<script type="text/javascript">
var myairline = new Array(10);
var first = 0;
var economy = 5;
var name;
var class;
<!-- Hide JavaScript from older browsers
//enter details
name=window.prompt("Please Enter your name");
class=window.prompt("Please Enter flight class. Enter 1 for first
class, 2 for second class");
//the following two if statements were put in instead of using a
function
if ( first == 4 && class == 1 ){
window.alert( "Do you want second class?" );
if (class == 2){
class=2;
}
}
if (economy == 9 && class == 2){
window.alert( "Do you want first class?" );
if (class == 1){
class=1;
}
}
//if the flight class is first class
if ( class = 1 ){
//this statement checks if the array is full (might need break
statement)
if (first == 4){
window.alert( "Next Plane leaves in 3 hours" );
}
//puts name into first class seat of array
array[first]=name;
//increments the index(also seat number) of the array and
prints out this new seatnumber, class and passenger name
first++;
document.write("Class: First Class, Passenger:+array[first]+<br
/>");
}
//if the flight class is economy class
if ( class = 2 ){
//this statement checks if the array is full (might need a
break statement to get out)
if (economy == 9){
window.alert( "Next Plane leaves in 3 hours" );
}
//puts name into economy seat of array
array[economy]=name;
//increments the index(also seat number) of the array and
prints out this new seat class and passenger name
first++;
document.write("Class: Economy Class,
Passenger:+array[first]+");
}
//print details
for (i=0;i<myairline.length;i++){
//flight details are output to the screen
document.write(myairline ++ "<br />")
}
// End hiding JavaScript from older browsers -->
</script>
</head>
</html>