Jump to content

Using an onclick in PHP


simedogz

Recommended Posts

hello all,

 

I inserted a javascript event handler 'onclick' into php code.  the onclick has a php variable in it that is supposed to trigger an alert when clicked.  I can't figure out how to escape the php variable correctly, so I just left it at the last thing I tried, which I know is wrong.  Any help is appreciated.

 

thanks

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function popUp(a) {
alert(a);
}
</script>

</head>

<body>

<?php
$gmail ='yaaah';

echo '<p onclick=popUp(\'$gmail\')>lkjlkjlkjlkjlkjlkj</p>';
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/233867-using-an-onclick-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.