How can php write a link to call a javascript function which uses a php variable ?
In this simple example I want the alert box to show the value (222) of the variable, but I cannot get beyond result1 showing the alert with "$myvar", or
result2 showing the alert with the variable but without a link.
<?php
$myvar = "222";
$link = 'alert("$myvar")';
$result1 = "";
$result1 .= "<a href='javascript:";
$result1 .= $link;
$result1 .= " '>";
$result1 .= $link;
$result1 .= "</a>";
$result2 = "";
$result2 .= "<script type='text/javascript'>";
$result2 .= "alert('$myvar');";
$result2 .= "</script>";
?>
<html>
<head>
</head>
<body>
<?php
echo $result1;
echo $result2;
?>
</body>
</html>
In this simple example I want the alert box to show the value (222) of the variable, but I cannot get beyond result1 showing the alert with "$myvar", or
result2 showing the alert with the variable but without a link.
<?php
$myvar = "222";
$link = 'alert("$myvar")';
$result1 = "";
$result1 .= "<a href='javascript:";
$result1 .= $link;
$result1 .= " '>";
$result1 .= $link;
$result1 .= "</a>";
$result2 = "";
$result2 .= "<script type='text/javascript'>";
$result2 .= "alert('$myvar');";
$result2 .= "</script>";
?>
<html>
<head>
</head>
<body>
<?php
echo $result1;
echo $result2;
?>
</body>
</html>