Create object property names using loop and input textboxes
<p>I am refactoring some code where I grab the values inputted into textboxes and use said values for calculations. The problem is rather than using document.getElementByID multiple times I want to loop through each textbox on the page and assigning each value to this object which I will pass to my calculation functions. I would also like to set the property names of this object by looking at the input textbox IDs and using the ID strings for the object property names.</p>

<p>See code below:</p>

<pre><code>$(document).ready(function() {

    var calcObj = new Object();
    $("input[id^='txt']").each(function(i, val) {
        calcObj[i] = this.value;
    });



    $.each(calcObj, function(i, val) {
        //        alert(val);
    });

}); 
</code></pre>

<p>As you can see when document is ready, object is created. There is a jquery .each loop to go through every input with id that contains txt. I am assigning this.value to object where index is i. </p>

<p>So I want to some how name the properties of this object and assign value so I can reference object property name elsewhere in the code where I pass this object to another function.</p>

<p>Thanks.</p>
