我有一个功能,我的回音是:PHP的回声问题
echo '<tr>
<td align="center" style="padding:5px;"><img src="/chat/emotes/smile.png" onclick="insertSmiley("hallo")"> <br>:illuminati:</td>
</tr>'
的问题是,onclick="insertSmiley("hallo")"
必须与'
,而不是与"
。如果我把它放在html中,一切正常,但是当我点击的时候,在php echo中什么也没有发生。
我的index.php在体内有此脚本:
<script type="text/javascript">
function insertSmiley(smiley)
{
var currentText = document.getElementById("send");
var smileyWithPadding = " " + smiley + " ";
currentText.value += smileyWithPadding;
currentText.focus();
}
</script>
和其它代码是我chat.php:
echo '<textarea id="send" maxlength="125" rows="2" placeholder="Enter your message"></textarea>
<tr>
<td align="center" style="padding:5px;"><img src="/chat/emotes/smile.png" onclick="insertSmiley("hallo")"> <br>:illuminati:</td>
</tr>
我真的觉得现在的问题是,因为我不能使用''
in echo,我需要它onClick...('hallo')
。
你错过了','在你的第一个'echo'年代末声明和第二个'echo'声明缺少'';'最后,也! –
您在双引号内使用''onclick =“insertSmiley(\'hallo \')”''双引号错误'' – jcubic
您正在生成错误的html:'onclick =“insertSmiley(”hallo“)”>'。 'hallo'的第一个'''引用终止了onclick属性,这意味着onclick中的JS代码是一个语法错误。 –