Skip to content Skip to sidebar Skip to footer

Javascript And Session Variables

I have a database that stores events in it and a page with a calendar object on it. When rendering the days it looks through the months events and if any match the current day bein

Solution 1:

Your session vars are controlled by the server, JS runs client side, and as such cannot modify the vars directly.

You need to make server requests using POST or GET and hidden iframes, or XMLHTTPRequest() calls to send data from the JS to the server, and then have your server side code handle the vars.

Add another query string variable that the page can use to trigger existing vs new.

Solution 2:

Add another query string variable that the page can use to trigger existing vs new.

Solution 3:

If you are using something like Struts2, you can have a hidden variable in your jsp

<s:hidden id="EditModeId" value="%{#session.EditMode}"/> 

And within javascript simply access this variable

alert(document.getElementById('EditModeId').value);

Solution 4:

You definitely need to add a variable to the target page. But I take it that you are doing a popup scenario, so you should be able to create a javascript function OpenWindow() and fire it off when the user clicks the link.

<script>functionOpenWindow(eventId, editMode)
{
    varwindow = window.open("popup.aspx?eventId=" + eventId + "&editMode=" + editMode);
}
</script>

On the server side you need to build the call to the OpenWindow function. For example:

onclick="OpenWindow(eventId=" + row["eventId"].ToString() + "&editMode=" + editMode.ToString() + ");"

So in other words, prep everything on the serverside to set your javascript to post all variables to the new page. Hope this helps.

Solution 5:

var page1 = document.getElementById("textbox").value; 
sessionStorage.setItem("page1content", page1);

in other page use this value as like session variable

document.getElementById("textbox2").value=sessionStorage.getItem("page1content");

Post a Comment for "Javascript And Session Variables"