Hi everyone,
my code is here Click Here

How i can get value of php variable in javascript, i have an div id=windowhead where i want to show username which i clicked

<a  class='users' href='#' >test</span></a>
<a  class='users' href='#' >test2</span></a>
<a  class='users' href='#' >Max</span></a>
<a  class='users' href='#' >John</span></a>   
<div id="warp">
    <div id="window">
      <div id="windowhead">username
        <div id ="close">&times;</div>
      </div>
      <div id="windowbody">

      </div>
    </div>
</div>
<?php $thisIsMyUberValue = "phoenix254"; ?>

<script>
    var uberValue = <?php echo $thisIsMyUberValue; ?>;
    alert("My value was: " + uberValue);
</script>

This should work, and prompt you "My value was: phoenix254". Go ahead, adjust it to your purposes.

I can't apply this personally to your Codepen, because I don't have access to your PHP variable, your folder structure and Codepen doesn't seem to support PHP.

Looking at your project, if I were you I would Google "Ajax", because the thing that you're attempting to create, can be made much easier. Just hinting.

Change your * into <span id="uname">tmp</span><br/>
And add before last }); this code:

        $('.users').click(function(e) {
            var txt = $(e.target).text();
            document.getElementById("uname").innerHTML = txt;
        });

});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.