Hi,
I have a simple code here to call a javascript function with a PHP variable but it doesn't work. And don't know the reason. Can someone help me out??
show_alert(<?php echo $test_message; ?>) should be very straight forward. But it didn't get interrupted by PHP before sending it to the browser.
<?php
$test_message= 'This is a test message';
?>
<html>
<head>
<script type="text/javascript">
function show_alert(msg)
{
alert(msg);
}
</script>
</head>
<body>
<input type="button" onclick="show_alert(<?php echo $test_message; ?>)" value="Show alert box" />
</body>
</html>