我试图将两个变量传递给 JavaScript 函数:输入本身和用户 ID。我使用输入的 onclick 属性调用该函数。
echo "<input type = 'submit' class = 'replyButton' id = 'replyButton'
value = 'reply' onclick = 'insertComment(this, $user_id);'>";
这些变量进入 JavaScript 函数:
function insertComment(input, user)
{
//use input and user id to carry out tasks.
}
给出的错误消息位于输入的 onclick 中对“insertComment()”的函数调用处。错误消息如下所示:
SyntaxError: identifier starts immediately after numeric literal
insertComment(this, 9f60d869342a);
我尝试了多种引号和点组合,并检查了 StackOverFlow 上的其他帖子。他们都无济于事。
非常感谢您帮助解决此错误。
你需要引用用户 ID
echo "<input type = 'submit' class = 'replyButton' id = 'replyButton'
value = 'reply' onclick = 'insertComment(this, \"$user_id\");'>";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)