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 ...
function jsignature()
{
var nsignature = document.getElementsByName("isignature")[0].value;
var signaturelist = [ "None Selected", "First name", "First & Lastname", "Known As" ];
var osignature = signaturelist[nsignature];
document.getElementById("esign").innerHTML = osignature;
}
However, naturally I don't want the words "First name" etc, I want the actual first name.
I tried the following, which I have seen as an answer to this exact problem on 3 or 4 websites ...
function jsignature()
{
var nsignature = document.getElementsByName("isignature")[0].value;
var fname = '<%=Session["firstname"]%>';
var signaturelist = [ "None Selected", fname, "First & Lastname", "Known As" ];
var osignature = signaturelist[nsignature];
document.getElementById("esign").innerHTML = osignature;
}
but the output was not the value stored in my session cookie "firstname" the output was actually "<%=Session["firstname"]%>"
I've also tried ...
var fname = <%=Session["firstname"]%>;
var fname = %=Session["firstname"]%;
var fname = Session["firstname"];
can anyone help please?
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.