简体   繁体   English

javascript onclick删除不起作用

[英]javascript onclick delete not working

Why is it that my onClick won't work? 为什么我的onClick无法使用?

When I click I get an error message like this: 当我单击时,会收到如下错误消息:

syntax error : identifier starts immediately after numeric literal

It will not determine the ID from the database, the database ID is varchar(50). 它不会从数据库确定ID,数据库ID为varchar(50)。

<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick='delete_Affiliate(".$row['affiliateid'].")'></a>

<script type="text/javascript"> 
    function delete_Affiliate(id){
        alert(id);

    }
</script>

Try this: 尝试这个:

delete_Affiliate(" <?php echo $row['affiliateid']; ?>")

That is, you need to echo the value from PHP. 也就是说,您需要从PHP中回显值。

Try this 尝试这个

<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick="delete_Affiliate(<?php echo $row['affiliateid'] ?>)"></a>

<script type="text/javascript"> 
function delete_Affiliate(id){
    alert(id);

}

there may be issue on this line 这条线上可能有问题
<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick='delete_Affiliate(".$row['affiliateid'].")'></a>
it should be 它应该是
<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick='delete_Affiliate("<?php echo $row['affiliateid']; ?>")'></a>

Can you please post your PHP script ? 您能发布您的PHP脚本吗? You should have something like : 你应该有这样的东西:

<?php

echo "<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick='delete_Affiliate(\"".$row['affiliateid']."\");return false;'></a>
<script type='text/javascript'> 
    function delete_Affiliate(id){
        alert(id);
    }
</script>";

?>

try this : 尝试这个 :

<?php 
 echo "<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick='delete_Affiliate(".$row['affiliateid'].");'></a>";
 ?>

or this : 或这个 :

<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick='delete_Affiliate("<?php echo $row['affiliateid'] ?>");'></a>

you have to add php tag and echo statement between your anchor tag like this 您必须像这样在锚标签之间添加php标签和echo语句

<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip'  onclick='delete_Affiliate("<?php echo $row['affiliateid']; ?>")'></a>

you didn't add this 您没有添加此

<?php echo $row['affiliateid']; ?> 

in your anchor tag so just add it and check it out. 在您的锚标记中,因此只需将其添加并签出即可。

I hope it will help you 希望对您有帮助

尝试这个

delete_Affiliate(<?php echo $row['affiliateid']; ?>);

使用此代码,希望它能工作

<a href='#' id='delete' title='Delete' class='icon-2 info-tooltip' onclick="delete_Affiliate(<?php echo $row['affiliateid'];?>);"></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM