Maintaining dynamic textbox control values into an array in javascript onchange event
<p>I need to maintain text box values into an array in javascript <code>onchange</code> event. The text box control is created dynammically in javascript function.  I have used below code. But at the end the array contains current element only. Previous values are not maintaining. How can I maintain textbox value each time entered.</p>

<pre><code>&lt;script type="text/javascript" language="javascript"&gt;
function DrawTextBox(j) {
    var imgElement = document.getElementById('myimage');
    var imgCoord = imgElement.getBoundingClientRect();
    var cl = imgCoord.left + 20;
    var x = x - cl;
    var y = y - imgCoord.top;
    var rect = document.getElementById(j);
    if (rect == null) {
        rect = document.createElement("div");
        rect.id = j;
        var pElement = document.getElementById("imgDiv");
        pElement.appendChild(rect);
    }
    if (w &lt; 0) {
        w = 10;
    }
    if (h &lt; 0) {
        h = 10;
    }
    var l = parseInt(document.getElementById("hright").value) + 150 + 'px';
    var style = rect.style;
    // style.width = w + "px";
    //style.height = h + "px";
    style.left = l;
    style.top = document.getElementById("htop").value;
    style.backgroundColor = "Transparent";
    //style.borderColor = "Blue";
    style.position = "absolute";
    style.borderStyle = "solid";
    style.borderWidth = 2 + "px";
    style.zIndex = 6000;
    document.getElementById(j).innerHTML = "&lt;textarea name=\"comments\" style=\" border:0\" Title=\"Enter Comment\" id=\"T1\" value=\"EnterComment:\" onchange=\"GetText()\" &gt;&lt;/textarea&gt;";
    //document.getElementById(i).innerHTML = "&lt;input type=\"Textarea\"...blah blah...&gt;&lt;/input&gt;";
    return rect;
}

function GetText() {
    array1.push(document.getElementById('T1').value);
    alert(array1.join(', '));
}
&lt;/script&gt;
</code></pre>
