title: How do I get Javascript to get a Session variable value
body: <p>I have a session variable load from a previous page, then I have a form with a Select box which allows a person to sign a document with either their first name, first and last name, or an alias. When that is chosen it activates the following function, which works fine as is ...</p>
  
  <pre><code>function jsignature()
  {
  var nsignature = document.getElementsByName("isignature")[0].value;
  var signaturelist = [ "None Selected", "First name", "First &amp; Lastname", "Known As" ];
  var osignature = signaturelist[nsignature];   
  document.getElementById("esign").innerHTML = osignature;
  }
  </code></pre>
  
  <p>However, naturally I don't want the words "First name" etc, I want the actual first name.</p>
  
  <p>I tried the following, which I have seen as an answer to this exact problem on 3 or 4 websites ...</p>
  
  <pre><code>function jsignature()
  {
  var nsignature = document.getElementsByName("isignature")[0].value;
  var fname = '&lt;%=Session["firstname"]%&gt;';
  var signaturelist = [ "None Selected", fname, "First &amp; Lastname", "Known As" ];
  var osignature = signaturelist[nsignature];   
  document.getElementById("esign").innerHTML = osignature;
  }
  </code></pre>
  
  <p>but the output was not the value stored in my session cookie "firstname" the output was actually "&lt;%=Session["firstname"]%>"</p>
  
  <p>I've also tried ...</p>
  
  <pre><code>var fname = &lt;%=Session["firstname"]%&gt;;
  var fname = %=Session["firstname"]%;
  var fname = Session["firstname"];
  </code></pre>
  
  <p>can anyone help please?</p>
  
  <p>EDIT: In response to the "duplicate" issue, my question was about session variables not PHP variables, even though my solution was the PHP variable, however my solution is not the same solution in the alleged duplicate question.</p>