[Register]  [Edit Profile]  [Edit Your Preferences]  [Search]
[Private Messages]  [Memberslist]  [FAQ]  [Login]
This Site Forum Index » » Bug reports » » testing sessionStorage form preservation
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.

  View Profile of Gaby de Wilde   Email Gaby de Wilde   Goto the website of Gaby de Wilde            Edit/Delete This Post   Reply with quote
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');
}



     Edit/Delete This Post   Reply with quote
  
Lock this Topic Move this Topic Delete this Topic
Powered by phpBB Version 1.4.4
Copyright © 2000 - 2001 The phpBB Group

phpBB Created this page in 0.010635 seconds.