When I put a string value into an onclick the console returns ‘Uncaught SyntaxError: Unexpected token ILLEGAL’? It works fine if its just a number but not if its a string!
Code:
document.getElementById("productMenu").innerHTML += "<div class=\"leftMenuItems\" onclick=\"javascript:showResources(" + p_codes + ");\">" + p_codes + " - " + p_names + "</div>";
<div class="leftMenuItems" onclick="javascript:showResources(1234ABC);">Product Name</div>
You are missing quotes
because
1234ABCis a string, while numbers don’t need quotes