I am trying to pass a PHP variable to a Javascript function but it keeps displaying as 'undefined'. I have the Javascript on a separate page and am including it on the page that I am calling the function from. Here is the code:
<?php $repname = $_SESSION['REPNAME']; ?>
<script type="text/javascript" src="js/chat.js"></script>
<input type="button" name="btn_send_chat" id="btn_send_chat" value="Send" onclick="javascript:sendChatText('<?php echo $repname;?>');" />
Here is js/chat.js:
function sendChatText(repname) {
alert(repname);
}