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 id="windowbody">

3 Years
Discussion Span
Last Post by Aeonix
<?php $thisIsMyUberValue = "phoenix254"; ?>

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

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.

Edited by Aeonix


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;


Edited by Aeonix

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.