dtcrw26206 2015-10-06 08:19
浏览 24
已采纳

php变量中的onclick函数[重复]

This question already has an answer here:

How to add onClick event on <a> tag which contains php variables

$delete = "<a onclick='return confirmDelete('deleterecord.php?chkid=$sl&table=$getid&path=$validURL');'><img src='images/dustbin.png' width='43px' height='30px'></a>";  // link not pass

//script

<script>
    function confirmDelete(delUrl) {
        if (confirm("Are you sure you want to delete")) {
            window.location = delUrl;
        }
    }
</script>
</div>
  • 写回答

2条回答 默认 最新

  • douliedu335997 2015-10-06 08:28
    关注

    1. $link = "deleterecord.php?chkid=$sl&table=$getid&path=$validURL";

    and use

    return confirmDelete(\"<?=$link?>\")
    

    2. Escape single quotes by using black slash before single quote:

      <img src=\'images/dustbin.png\' width=\'43px\' height=\'30px\'>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?