I recently created a modal popup using CSS by following a helpful tutorial that can be found at this link:
Now, I am curious about how to store the value entered in a textbox as session data. I came across some code in another tutorial that demonstrated how to save email input into session storage:
(function () {
var text = document.getElementById('email');
text.addEventListener('keyup', function () {
sessionStorage.text = text.value;
}, false);
});
However, when attempting to display the stored value on a different page (not within the modal popup), it doesn't seem to work. The text does not appear as expected.
document.getElementById('storage').innerHTML = 'Your stored value is ' + sessionStorage.text;
I am starting to wonder if there are specific considerations to keep in mind when dealing with modal popups that perhaps I have overlooked?
Edit:
One important detail I forgot to mention is that the second line of code is executed in a separate tab or window, which could possibly impact its functionality. Additionally, I encountered these errors: "TypeError: document.getElementById(...) is null" and "ReferenceError: $ is not defined."
Based on feedback from others, it appears that performing this action from a popup window may not be possible. I am now exploring alternative methods such as sending the information back to the parent window, where the text can then be saved into session storage. Any suggestions or insights would be greatly appreciated!