开发者

PHP javascript link id

<?php
//connect to database .... 
//select query .... 
if(isset($_GET["link"])==false){
echo "sample 1"; 
}else{
echo "sample 2" ;
} 
?>
<script type="javascript">
function Link(id)
{

loca开发者_高级运维tion.href='linktest.php&link='+id;

}
</script>
<html>
<input type="button" value="link test" onclick="javascript: Link<?php echo $row['id']; ?>"> 
</html>

(assumed question) How do I force the onclick event to contain the value of $row['id']?


You do not do anything with the value of $row['id'], you need to display it so you need to provide an echo statement.

Therefore, instead of,

onclick="javascript: Link<?php $row['id']; ?>

do this,

onclick="javascript: Link(<?php echo $row['id']; ?>)

As commented, you also forgot parenthesis around the function call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜