I'm puzzled as to why the result of the Javascript computation does not appear in the input field of id "Between." I ran the JS through jshint.com and it found no errors. This will be used in an iPhone environment on an html page. I'm very new to JS. I picked up some simple math code elsewhere and massaged it into the shape you see here. Can you JS coders show me where my script has gone wrong?
function heatpit(form) {
var e = form.elements.LENGTH.value, // put LENGTH (number of minutes) field value into variable e
f = form.elements.STOPS.value, // put STOPS field value into variable f
secs2 = e * 60, // convert the minutes into seconds
periods = f + '1', // add 1 to the pit stop number get the total number of divisions throughout the LENGTH
result2 = secs2 / periods, // divide the LENGTH by the number of periods
seconds = result2 % 60, // use modulus operator to get the remainder and convert it into seconds figure
minutes = Math.floor(result2 / 60), // get the minute figure as a digit
time = minutes + ":" + seconds; // concatenate everything into minutes and seconds
form.elements.between.value = time; // display "time" value in the "between" field
}
var resultPitStops = document.getElementById('resultPitStops');
resultPitStops.onclick = function () {
var form = document.getElementById('form2');
heatpit(form);
};