title: Value array selector as a variable jquery
body: <p>I hope someone can help me. I been crashing down my head trying to end up with a solution for this, here is the deal, I have a function passing through some variables like this:</p>
  
  <pre><code>function createTaskView(results, listName, container, url, groupby) {
  </code></pre>
  
  <p>The variables are so simples, "results" it's an array, the other ones are simply strings. So far so good.</p>
  
  <p>Then I start an $.each loop in the array like this:</p>
  
  <pre><code>function createTaskView(results, listName, container, url, groupby) {
  
      $.each(results, function (index, task) {
          var tr = '&lt;tr&gt;' +
                     '&lt;td&gt;&lt;a href="'+ url +'Lists/'+ listName +'/EditForm.aspx?ID='+ task.ID +' "&gt;' + task.ID + '&lt;/a&gt;&lt;/td&gt;' +
                     '&lt;td&gt;' + task.Year + '&lt;/td&gt;' +
                     '&lt;td&gt;' + task.Site_x0020_Name + '&lt;/td&gt;' +
                  '&lt;/tr&gt;';
  
          $(container + ' .' + task.groupby).append(tr);
  
      });
  
  });
  </code></pre>
  
  <p>The problems starts here</p>
  
  <pre><code>$(container + ' .' + task.groupby).append(tr);
  </code></pre>
  
  <p>I know there is no key in my DB call "groupby", I meant to use the string value passed into the function in here: </p>
  
  <pre><code>function createTaskView(results, listName, container, url, groupby) {
  </code></pre>
  
  <p>So, if the variable groupby is like this:</p>
  
  <pre><code>var groupby = Year;
  </code></pre>
  
  <p>I want this:</p>
  
  <pre><code>task.groupby
  </code></pre>
  
  <p>To be equal like this:</p>
  
  <pre><code>task.Year
  </code></pre>
  
  <p>I don't know if I make myself clear.
  Please someone help me.</p>
  
  <p>Thanks.</p>