Javascript - use class name to specify which variable to assign value to
<p>I'm trying to be clever with some efficient Javascript but it's causing me headaches and lots of fruitless searching.</p>

<p>I have a set of inputs in a table, each with a given class:</p>

<pre><code>...
&lt;tr&gt;
&lt;td&gt;&lt;input name="name" type="text" class="markertitle"/&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="desc" type="text" class="markerdescription"/&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="address" type="text" class="markeraddress"/&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="url" type="text" class="markerurl"/&gt;&lt;/td&gt;
&lt;/tr&gt;
...
</code></pre>

<p>I want to take the value of those classes, use it to specify a given variable (which already exists), then assign the value of the input (using +=) to that variable.</p>

<p>This is what I've come up with, but no joy:</p>

<pre><code>    var markertitle = {};
    var markerdescription = {};
    var markeraddress = {};
    var markerurl = {};
    $('#markermatrixadd input').each(function(){
        var field = $(this).attr('class');
        window[field] += $(this).val() + ',';

    });
</code></pre>

<p>It's dead simple I'm sure, but I think my brain's a bit fried :(</p>
