JS: adding text to text area issue
<p>Hi I'm trying to implement a solution that was posed on this question:
<a href="http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery">http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery</a></p>

<p>But coming unstuck.</p>

<p>This flat function works fine when adding some dummy text into a textarea element:</p>

<pre><code>function add_to() {
        $('#ad_textarea').val($('#ad_textarea').val()+'test');
}
</code></pre>

<p>However, when I try to wire up this function to a variable, it breaks:</p>

<pre><code>function add_to(word) {
            $('#ad_textarea').val($('#ad_textarea').val()+word);
    }
</code></pre>

<p>when being called from this line of code:</p>

<pre><code>&lt;?php foreach ($words as $word) {
    echo    "&lt;li class='$word[0]'&gt;&lt;a href='#' onclick='add_to('$word');'&gt;$word&lt;/a&gt;&lt;/li&gt;";
    } 
    ?&gt;
</code></pre>

<p>I have looked at the outputted code, and it looks clean:</p>

<pre><code>&lt;li class='a'&gt;&lt;a href='#' onclick='add_to('aardvark');'&gt;aardvark&lt;/a&gt;&lt;/li&gt;
</code></pre>

<p>I'm ultimately trying to get aardvark to print out in the textarea. Can anyone spot my slip up?</p>

<p>TIA</p>
