0

I am trying to pass the value userSession(id of the user) to the javascript. But i can't seem to pass the session id to var master. I am a new to javascript here

$(document).ready(function(){
        $('#token-btn').hide();
        infoBox.onDisplay = function(ln){
           var master = "<?php echo $_SESSION['userSession']; ?>";
        if(ln.id == master)
            $('#token-btn')[0].style.display = "none";
        else
            $('#token-btn')[0].style.display = "";

        };
    });

main.php

    <?php
        $id = $_SESSION['userSession'];
    ?>
    <li><a id="token-btn" href="#" type="button" class="btn btn-primary"> Give Invitation Token</a>    </li>
Synetrix
  • 59
  • 2
  • 12

1 Answers1

0

My earlier answer was wrong, so I have removed it.
Your php code is not getting parsed, so check your file extension. You are probably trying this on a .js file like @pete has commented.

zacurry
  • 876
  • 3
  • 12
  • 25