Click to See Complete Forum and Search --> : Help with creating an array.


james kelsey
06-30-2004, 02:33 PM
I have a simple problem, but I dont know how to correct it.
The following code needs to be modified so that a window prompts the user to put in their marks, for example "please input marks for question1" then "question 2" etc till there are 5 marks.
Can anybody help?

var marksArray = new Array(5);

document.write('Array program to display marks earned in TMA');
for (var mark = 0; mark < marksArray.length; mark = mark + 1)
{
marksArray[mark] = window.prompt('Enter mark', '')
};
document.write('<BR>' + '<BR>');
document.write('Confirmation of TMA marks' + '<BR>' + '<BR>');

for (var mark = 0; mark < marksArray.length; mark = mark + 1)
{
document.write(marksArray[mark] + '<BR>')
}

theBody44
06-30-2004, 03:39 PM
Is this what you are looking for?? marksArray[mark] = window.prompt('Please input marks for question ' + (mark+1), '')