You are mixing the two worlds here, and that is never going to end up well. Without any further complications, I would recommend that you bring these elements to the client-side and consider using JavaScript APIs such as
sessionStorage
to maintain this session. Now, since the session values are offline, it doesn't require a postback and updating the values because browser can be queried to check if the session exists or did it expire.
Window.sessionStorage - Web APIs | MDN[
^]