开发者

PHP javascript link id

开发者 https://www.devze.com 2023-01-01 20:36 出处:网络
<?php //connect to database .... //select query .... if(isset($_GET[\"link\"])==false){ echo \"sample 1\";
<?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

精彩评论

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