-1

I am trying to join three languages with no luck.
I need to call javascript function to add clicked text to textarea, which is inside php with html.

This is what I tried as my best with no luck:

$hint .= "<br>" . "<a href='#' onclick='addtext(". $name .")'> " . $name . " </a> ";

I think I need somehow to echo that $name inside addtext() function, but don't know how, because I can't write statement inside another. I think so, because when I debug code, I see that this is recognized not as string but as attribute property:

enter image description here

JS function:

function addtext(str) {
    var newtext = str;
    document.getElementById("msg").value += newtext;
}

Please suggest a working solution to this problem.

Neone
  • 482
  • 1
  • 9
  • 21

1 Answers1

0

Put your string inside function with quotation marks ;)