wrote:You opened onclick with double quote and tried to close with single. Switched to both single. try that.
Good observation, but the suggested solution is not correct.
In this case, a printf might be better:
printf('<tr><td><a href="#" onclick="document.getElementById(\'name\').value = \'%1$s\';">%1$s</a></td>',
htmlspecialchars($dirArray['index']));