Hi
i currently have this code for an assignment i'm working my way through
[code=javascript]
var flightTimes = new Array ('07:15', '08:05', '08:30', '09:30', '09:50', '10:00', '10:20', '10:45', '11:00', '12:00', '13:00', '13:05', '13:15', '13:35', '14:10', '15:00', '16:00', '16:40', '16:55', '17:00', '19:30', '21:00', '22:00', '23:20', '23:59');
var flightDestinati ons = new Array ('Arkham', 'Hensonville', 'Stepford', 'Maycomb', 'Bay Port', 'Denton', 'Waldon City', 'Denton', 'Denton', 'Waldon City', 'Arkham', 'Maycomb', 'Bay Port', 'Stepford', 'Denton', 'Maycomb', 'Waldon City', 'Hensonville', 'Denton', 'Denton', 'Stepford', 'Bay Port', 'Hensonville', 'Waldon City', 'Arkham');
var flightOperators = new Array ('Miskatonic', 'SuperSwift', 'Aalto', 'DynaJet', 'Oceanic', 'Aalto', 'Aalto', 'MidSouthCentra l Air', 'SuperSwift', 'SuperSwift', 'Miskatonic', 'DynaJet', 'Miskatonic', 'SuperSwift', 'MidSouthCentra l Air', 'Aalto', 'SuperSwift', 'Aalto', 'MidSouthCentra l Air', 'Aalto', 'DynaJet', 'Oceanic', 'SuperSwift', 'Aalto', 'Miskatonic');
var flightFares = new Array (300, 100, 150, 75, 250, 150, 75, 125, 100, 25, 600, 75, 400, 250, 300, 250, 150, 200, 125, 150, 75, 100, 100, 50, 300);
function displayMessage( aMessage)
{
document.getEle mentById('theFl ights').innerHT ML = aMessage;
}
function showTimetable()
{
for (var i = 0; i <= flightTimes.len gth; i = i + 1)
{
if (i <= flightTimes.len gth - 1)
{
displayMessage( (i + 1) + ' ' + flightTimes[i] + ' to ' + flightDestinati ons[i] + ' operated by ' + flightOperators[i] + '. $' + flightFares[i] + '<BR>');
}
}
/*for (var i = 0; i <= flightTimes.len gth; i = i + 1)
{
if (i <= flightTimes.len gth - 1)
{
document.write( (i + 1) + ' ' + flightTimes[i] + ' to ' + flightDestinati ons[i] + ' operated by ' + flightOperators[i] + '. $' + flightFares[i] + '<BR>');
}
}*/
}
[/code]
the trouble i'm having is getting the displayMessage to write down all of the Array's in a <DIV>
it works fine when you do document.write but when you do display message it works it way through the arrays only displaying the last one?
i can't really think of which way to do it if i'm doing it correct in the first place?
any help is much appreciated
z
i currently have this code for an assignment i'm working my way through
[code=javascript]
var flightTimes = new Array ('07:15', '08:05', '08:30', '09:30', '09:50', '10:00', '10:20', '10:45', '11:00', '12:00', '13:00', '13:05', '13:15', '13:35', '14:10', '15:00', '16:00', '16:40', '16:55', '17:00', '19:30', '21:00', '22:00', '23:20', '23:59');
var flightDestinati ons = new Array ('Arkham', 'Hensonville', 'Stepford', 'Maycomb', 'Bay Port', 'Denton', 'Waldon City', 'Denton', 'Denton', 'Waldon City', 'Arkham', 'Maycomb', 'Bay Port', 'Stepford', 'Denton', 'Maycomb', 'Waldon City', 'Hensonville', 'Denton', 'Denton', 'Stepford', 'Bay Port', 'Hensonville', 'Waldon City', 'Arkham');
var flightOperators = new Array ('Miskatonic', 'SuperSwift', 'Aalto', 'DynaJet', 'Oceanic', 'Aalto', 'Aalto', 'MidSouthCentra l Air', 'SuperSwift', 'SuperSwift', 'Miskatonic', 'DynaJet', 'Miskatonic', 'SuperSwift', 'MidSouthCentra l Air', 'Aalto', 'SuperSwift', 'Aalto', 'MidSouthCentra l Air', 'Aalto', 'DynaJet', 'Oceanic', 'SuperSwift', 'Aalto', 'Miskatonic');
var flightFares = new Array (300, 100, 150, 75, 250, 150, 75, 125, 100, 25, 600, 75, 400, 250, 300, 250, 150, 200, 125, 150, 75, 100, 100, 50, 300);
function displayMessage( aMessage)
{
document.getEle mentById('theFl ights').innerHT ML = aMessage;
}
function showTimetable()
{
for (var i = 0; i <= flightTimes.len gth; i = i + 1)
{
if (i <= flightTimes.len gth - 1)
{
displayMessage( (i + 1) + ' ' + flightTimes[i] + ' to ' + flightDestinati ons[i] + ' operated by ' + flightOperators[i] + '. $' + flightFares[i] + '<BR>');
}
}
/*for (var i = 0; i <= flightTimes.len gth; i = i + 1)
{
if (i <= flightTimes.len gth - 1)
{
document.write( (i + 1) + ' ' + flightTimes[i] + ' to ' + flightDestinati ons[i] + ' operated by ' + flightOperators[i] + '. $' + flightFares[i] + '<BR>');
}
}*/
}
[/code]
the trouble i'm having is getting the displayMessage to write down all of the Array's in a <DIV>
it works fine when you do document.write but when you do display message it works it way through the arrays only displaying the last one?
i can't really think of which way to do it if i'm doing it correct in the first place?
any help is much appreciated
z
Comment