| Author |
testing sessionStorage form preservation |
Gaby de Wilde
Joined: Nov 14, 2021 Posts: 13 From: The land of cheese
| Posted: 2024-09-03 12:02  
In the good old days form values would persist if one navigated away from the page. This forum is full of "error, please go back try again" messages when a form isn't sufficiently filled out. Then you go back and the form is empty.
 
|
Anonymous Unregistered User | Posted: 2024-09-05 06:18  
In order to accomplish this I had to modify the front end. I was planning not to do that but it seems there was no other choice. Vanishing postings is to uncool.
For newtopic.php and reply.php it only took putting the post text and title back but for editpost.php I had to do it like this(?)
Code:
|
document.querySelector('form').addEventListener('submit',function(e){
sessionStorage.setItem('postid', "<?php echo $post_id; ?>");
sessionStorage.setItem('message', document.querySelector('[NAME="message"]').value);
sessionStorage.setItem('subject', document.querySelector('[NAME="subject"]').value);
});
if(sessionStorage.getItem('postid') == "<?php echo $post_id; ?>"){
document.querySelector('[NAME="message"]').value = sessionStorage.getItem('message');
document.querySelector('[NAME="subject"]').value = sessionStorage.getItem('subject');
}
|
|
 
|