I am using my PHP skills to understand how JS works and have been able to figure out a lot. However, I’m stumped by how to output the results to a form’s text field where an array is involved.

I’ll give you the full code (which has not been finalized yet), but in a nutshell, I’m applying calculations to an array of integers. The user chooses the array he wants to calculate, and the arrays all have a different amount of integers in them. After each calculation I round up and down the numbers and calculate them again. After that, I output the results of each number to a text field. That’s where I encounter the difficulty. Here’s the code. I separated out the troubling line and put ?? with it.

Note that this has not been tested yet. I have no idea whether this first draft will even work.

```
var ans = document.getElementById('ans'); // this is the result that comes from a prior calculation. It's the basis of the new calculations.
var ratio = form.elements.ans.value; // the result field that returned the user's spur and pinion input calculation
var choiceSpurs;
<!-- evaluate the spur gear list choice from drop-down menu, and establish the array of spurs to calculate -->
switch (choiceSpurs)
{
case (choiceSpurs=='sc10_4x4'):
choiceSpurs = "spurs['58', '60', '62', '93']";
break;
case (choiceSpurs=='sc10'):
choiceSpurs = "spurs['75', '78', '81', '84', '87']";
break;
case (choiceSpurs=='sc8'):
choiceSpurs = "spurs['50', '52', '54']";
break;
case (choiceSpurs=='b44'):
choiceSpurs = "spurs['72', '75', '78', '81', '84']";
break;
case (choiceSpurs=='b4t4'):
choiceSpurs = "spurs['72', '75', '78', '81', '84', '87']";
break;
case (choiceSpurs=='gt2'):
choiceSpurs = "spurs['54', '55', '56']";
break;
default: "spurs['72', '75', '78', '81', '84', '87'];
};
var spurArrayLength = choiceSpurs.length; <!-- get the number of items in the array -->
function alternateRatios () {
var L = spurArrayLength - 1; // get the count of the array; subtract 1 to assume length starts at zero like array does
var i = 0; <!-- start the increment count at zero because it'll also be used to point to the object in the array, which starts counting at zero -->
while (i <= L) { <!-- while the count is still within the range of objects in the choiceSpurs array... -->
var pinion . i = spurs[i] / ratio; <!-- ... divide the array's spur tooth count by the ratio -->
i++; // up the increment and work on the next object in the array
}
<!-- round up and round down each of the results to get the pinion tooth count -->
var i = 0;
while (i <= L) {
var pinionUP . i = Math.ceil(pinion . i);
var pinionDOWN . i = Math.floor(pinion . i);
i++; <!-- up the increment -->
}
<!-- divide new spur/pinion combinations to get new ratios -->
var i = 0; // start the increment count
while (i <= L) {
var ratioUP . i = spurs[i] / pinionUP . i;
var ratioDOWN . i = spurs[i] / pinionDOWN . i;
i++;
}
<!-- display results to user -->
var i = 0;
var original = "Original ratio: " . ratio;
var try = " Try: ";
while (i <= L) {
display . i = spurs[i] . i . "/" . pinionUP . i . " = " . ratioUP . i. ", " . spurs[i] . "/" . pinionDOWN . i . " = " . ratioDOWN . i. ", ";
form.elements.moreRatios.value = ??
i++;
}
} <!-- end of function -->
var buttonNewRatios = document.getElementById('buttonNewsRatios');
buttonNewRatios.onclick = function () {
var form = document.getElementByID('form2');
alternateRatios(form);
};
```