title: How to eval or parse jquery code that's pulled in as a .val() value?
body: <p>I have a situation where I want to allow a user of my software to be able to paste in some jquery code into a textarea and click a button to trigger a .change event function.</p>
  
  <p>In this function a var is created based on the .val of that textarea.  Then this var is used in the function to manipulate some CSS.</p>
  
  <p>It's all working fine except the fact that the var acts totally different when it pulls in the .val as apposed to hard coding it.  In other words, if I were to hard code:</p>
  
  <p>var test_var =  new Array(3)</p>
  
  <pre><code>for (i=0; i &lt;3; i++)
  test[i]=new Array(3)
  
  test[0][1] = "option-1"
  test[0][2] = "option-1-value"
  
  test[1][1] = "option-2"
  test[1][2] = "option-2-value"
  
  test[2][1] = "option-3"
  test[2][2] = "optoin-3-value"
  </code></pre>
  
  <p>Then it would execute the array code in the function.</p>
  
  <p>But if I were to say:</p>
  
  <p>var test_var = $('#textarea-content').val();</p>
  
  <p>And then paste the exact array code mentioned above in the textarea then the var text_var becomes the text (instead of becoming the executed code).</p>
  
  <p>I've tested this by doing an alert(text_var) and it's clear that when the var is hard coded it comes back as executed code, but when the var is pulling in the .val() of the textarea it's just the text, unexecuted.</p>
  
  <p>So it's treating the hard coded version as code and the .val() version as plain text.</p>
  
  <p>With PHP I would do something like eval(test_var); to treat it as executable code and not just plain text and I know eval exists in javascript, but I can't seem to get it to fix my problem.</p>
  
  <p>So if any of this make sense and you have a possible solution I'd love to hear it.</p>
  
  <p>Thanks! :)</p>
  
  <p>Eric</p>