JavaScript: using one text box value as basis for loop to capture values in second text box?
<p>I have a script that needs to capture a value (textbox1), and use the value to establish the size of an array. Then i need to use a different textbox (tesxtbox2) to capture the values to populate the array and then process a few calculations.</p>

<p>I can capture the first value fine, size the array, and populate the array IF i use window prompts for the data capture.  I cannot figure out how to replace the prompt method with a text box capture.</p>

<p>Here is the code- and the comments show where I am stuck. In essence, i need to replace the "window.prompt" section with "get element by id" and use the text box, looping thorough the values until the initial number entered (text box1) is fulfilled.</p>

<pre><code>            &lt;html&gt;
           &lt;head&gt;
              &lt;meta charset = "utf-8"&gt;
              &lt;title&gt;Variance and Standard Deviation&lt;/title&gt;

            &lt;style type = "text/css"&gt;

            #placement {
            width: 50%;
            padding: 0 0px;
            align:right;
            text-align: left;
            }

            #sorted {
            width: 50%;
            padding: 0 0px;
            float:left;
            text-align: left;
            }

            #mean,{
            width: 50%;
            padding: 0 0px;
            align:right;
            text-align: left;
            } 
            #variance,{
            width: 50%;
            padding: 0 0px;
            align:right;
            text-align: left;
            } 
            #deviation,{
            width: 50%;
            padding: 0 0px;
            position: relative;
            text-align: left;
            } 

            &lt;/style&gt;

            &lt;script&gt;

            //declare and intialize variables 
            var capCount = 0; //capture count of variables to be entered
            var count = 0; //parse captured count to an integer
            var arrayTotal=0 ; //total of all values entered into array for math calcs
            var arrayAverage=0; //average (mean) of values in array
            var sortedArray = 0; //array sorted in ascending order
            var values = 0;  //values entered into text box for array population


            function start(formInfo) 
                {
                    var countField = document.getElementById( "count" ); // gets entry from count field on form
                    var capCount = countField.value;    
                    var count = parseInt (capCount);

                    var valueArray = new Array(); // allocate empty array   
                    //start capture and populate array loop
                    for ( var i = 0; i &lt; count; ++i ) //using loops count, prompts user to enter variables until count of loops (count) is reached
                    //STUCK HERE- replace variable capture from window prompt to get value from text box
                    // rather than using window prompt box, need to capture input from the "value" text box,
                    // loop through the text box each time a value is entered and process when the last value (loops equal to count) is entered
                        {
                        var variable = window.prompt("Please enter a value for value " + (i + 1) + "" );  //prompts user to enter a value
                        //var variable = document.getElementById("value");
                        valueArray [ i ] = variable ;
                        } //end capture for loop


                    //calls sort function to sort array into ascending order
                    valueArray.sort ( sort );

                    //calls calcuate function to conduct math and get results
                    calculate ( valueArray );

                }// end build array function



            //sort function
            function sort ( value1, value2 )
            {
                return parseInt ( value1 ) - parseInt( value2 );
            } //end sort

            //calcuate function
            function calculate (theArray)
            {
                //declare variables
                n = 0;
                arrayTotal = 0;
                total_sqr = 0;
                for (var i = 0; i &lt; theArray.length; ++i )
                {   
                arrayTotal += +theArray[i];
                n = (n + 1);
                total_sqr += (+theArray[i] * +theArray[i]);
                }
                //mean, variance, deviation calcs
                mean = (arrayTotal / theArray.length); //calcuate mean
                variance = (total_sqr - ((arrayTotal*arrayTotal)/n))/(n - 1);
                deviation = Math.sqrt( variance) ;

                //calls output function to output the resuls of the script
                output( "The sorted order of the values entered is", theArray, document.getElementById( "sorted" ) ); 
                output( "The mean of the values entered is", mean.toFixed(2), document.getElementById( "mean" ) );      
                output( "The variance of the values entered is", variance.toFixed(2), document.getElementById( "variance" ) );  
                output( "The standard deviation of the values entered is", deviation.toFixed(2), document.getElementById( "deviation" ) );

            } //end calculations

            //output function
            function output ( heading, data, results )
            {

                var content = "&lt;p&gt;" + heading + "&lt;/p&gt;&lt;p&gt;" + data + "&lt;/p&gt;" ;
                results.innerHTML = content; // place the table in the output element
            } //end output

            &lt;/script&gt;
           &lt;/head&gt;
           &lt;body&gt;

           &lt;body&gt;
                &lt;P&gt;&lt;h2&gt;This Page calcuates mean, variance and standard deviation&lt;/h2&gt;&lt;/p&gt;
                &lt;form action = "#"&gt;
                    &lt;p&gt;&lt;label&gt;&lt;h3&gt;Enter the # of values to process and click submit:&lt;/h3&gt;
                    &lt;input id = "count" type = "number" size = "10"&gt;&lt;/label&gt;

                &lt;div&gt;
                &lt;input type="button" value="Submit #of values to " onClick="start(this.form);"&gt;
                &lt;/div&gt;

                &lt;p&gt;&lt;label&gt;&lt;h3&gt;Enter the x value to process:&lt;/h3&gt;
                &lt;input id = "value" type = "number" size = "10"&gt;&lt;/label&gt;

                &lt;p&gt;
                &lt;input type="button" value="process your values" onClick="process(this.form);"&gt;
                &lt;/p&gt;


                &lt;/form&gt;

           &lt;div id = "sorted"&gt;&lt;/div&gt; 
           &lt;div id = "placement"&gt;
                &lt;div id = "mean"&gt;&lt;/div&gt;
                &lt;div id = "variance"&gt;&lt;/div&gt;
                &lt;div id = "deviation"&gt;&lt;/div&gt;
           &lt;/div&gt;
           &lt;/body&gt;
        &lt;/html&gt;
</code></pre>
