Hi I'm trying to implement a solution that was posed on this question: Insert text into textarea with jQuery
But coming unstuck.
This flat function works fine when adding some dummy text into a textarea element:
function add_to() {
$('#ad_textarea').val($('#ad_textarea').val()+'test');
}
However, when I try to wire up this function to a variable, it breaks:
function add_to(word) {
$('#ad_textarea').val($('#ad_textarea').val()+word);
}
when being called from this line of code:
<?php foreach ($words as $word) {
echo "<li class='$word[0]'><a href='#' onclick='add_to('$word');'>$word</a></li>";
}
?>
I have looked at the outputted code, and it looks clean:
<li class='a'><a href='#' onclick='add_to('aardvark');'>aardvark</a></li>
I'm ultimately trying to get aardvark to print out in the textarea. Can anyone spot my slip up?
TIA