<html>
<head>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
function login(t)
{
var t = '<?php echo $id; ?>';
alert(t);
}
-->
</SCRIPT>
</head>
<body> 
<?php
$id=$_GET['id'];
print "<input type='button' name='button' value='button' onClick='login('$id')'>";
?>
</body>
</html>

i want to alert the variable using onclick function.

Umm.. you are passing the id as a parameter. Why are you trying to assign the value of $id to t (in javascript function) ?

<html>
<head>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
function login(t) {
alert(t);
}
-->
</SCRIPT>
</head>
<body> 
<?php
$id=$_GET['id'];
print "<input type='button' name='button' value='button' onClick=login('$id')>";
?>
</body>
</html>

This works just fine !

commented: Another great snippet +7

thank u.it's working.....

:) You are welcome!

How would you do this without a button?

Thanks.

Bill

very nice yar. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.