I'm struggling to get this working. The dispatch() function seems to be getting triggered (tested with the alert), but the innerHTML lines don't seem to work.
Also, i doesn't seem to increase despite the i++ in the onSubmit.
Here is the function in question:
function dispatch(passengers,i,timesArray)
{
alert('value of i is '+i);
timesArray[i]=getTime();
var avTime=getAverageTime(timesArrary);
var throughput=passengers*3600000/avTime;
if(i==0)
{
document.getElementById('output').innerHTML = 'Calculating...';
}
else
{
document.getElementById('output').innerHTML = throughput;
}
//and possibly a list (w/e)
}
And here is the form:
<form method="post" action="javascript:void(0);" name="applesForm" onSubmit="dispatch(document.applesForm.numPassengers.value, num, times);i++;">
<input type="text" name="numApples" id="numPassengers" />
<br/>
<input type="submit" name="Submit" value="Press on Dispatch!"/>
</form>
Could this be a question of not being able to change global variables from inside the function?
Or, is there something wrong with the avTime or throughput lines which is making the function cease?
alertthrough your function, and seeing where it fails.timesArray[i]=getTime();, would this line not successfully changetimes[num]?