Javascript: How to Keep Persistant Array Data
<p>I'm trying to build an array in javascript that contains a list of ids.  Here is a simplified version of the function that I have...</p>

<pre><code>function updateCost(id) {
    var inputArray = [];
    inputArray.push(id);
}
</code></pre>

<p>And here is the html code...</p>

<pre><code>&lt;input type="file" name="field1" id="field1" onchange="updateCost('1');" /&gt;
&lt;input type="file" name="field2" id="field2" onchange="updateCost('2');" /&gt;
&lt;input type="file" name="field3" id="field3" onchange="updateCost('3');" /&gt;
...
</code></pre>

<p>What I would like to happen, is each time I select a file from my computer using one of the file input fields that I have, I would like the id of that input field to be stored in the inputArray array.  However, every time I select a file, it adds that id to the array, but it doesn't append it to the array, so everything else in the array is deleted, leaving only one entry in the array.</p>

<p>Is there any way to make the array data persistent so it will grow each time I use one of the of the file input fields?</p>

<p>Thanks!</p>
