JS not executing

JS not executing

本文关键字:executing not JS      更新时间:2023-09-26

我有这个代码:

if ($has_freechat1 && $has_freechat2)
{
    if (($has_freechat1['confirmed'] == 1) && ($has_freechat2['confirmed'] == 1))
    { 
        $was_clicked = 0;
?>
<a href="freechatcontacts.php?id=<?php echo $id_to.$was_clicked; ?>" class="charcoal_link" style="line-height: 20px;" name="message" id="message" onClick="return send('<?php echo $was_clicked;?> return false;')">
<?php echo $uniqueCode1?><span class="pink_text"><?php echo $uniqueCode2?></span><?php echo $uniqueCode3?>
</a>
&nbsp;&nbsp;       
<?php                         
        if ($was_clicked == 1)
        {
?>
  <tr>
    <td><input name="password" type="textarea" rows="10" cols="20" value="<?php echo $aCleanPost['message']['value']?>" /></td>
  </tr>        
  <tr>
    <td><br /><input name="cmdSubmit" type="submit" value="Send" /><br/>&nbsp;</td>
 </tr>
 <?php         
        }
 }

上面显示了一个uniquecode链接,当我点击它时,我希望显示一个html文本区域,这样用户就可以输入短消息。。onlcicksend()是一个JS函数,但它不执行它,所以我可以将$was_clicked设置为1

我怎样才能解决这个问题?请帮忙谢谢

编辑来自注释的sendMessage函数:

<script type="text/JavaScript">
function send(val)
{
   val = 1; //was clicked 
   return val;
}
</script>
您的onclick处理程序必须调用javascript函数,而不是php函数。

您的代码语法似乎是错误的。

onClick="return send('<?php echo $was_clicked;?> return false;')">

尝试

onClick="javascript:send('<?php echo $was_clicked;?>'); return false;">