the Reset button, clearing the fields ANYTIME

By: Larry Kolinek | Asked: 05/11/2023
ForumsCategory: General questionsthe Reset button, clearing the fields ANYTIME
Larry Kolinek asked 12 months ago
Hi, When you turn on the FF reset button, it only works BEFORE you submit the form. If you happened to come back to the form, the reset button does not work :(

FYI. I'm populating the fields via PHP session variables. So the form fields are always populated anytime the user views the form. My use case, the form is a Search Criteria form. Anyway, I need to have the reset/clear button work anytime a user clicks the button. Thinking I only need:
  1. execute the FF way of clearing the fields OR
  2. write some javascript myself to clear the fields
assuming 2nd options is easier :)
but where do I put the javascript call via the click of the reset button? wondering if anyone has done this OR could help point me in the right direction   THANK YOU! Larry
2 Answers
Chris AdamsChris Adams answered 12 months ago
Hi Larry, Have you tried this:
Larry Kolinek replied 12 months ago

oh my... that was easy (easier) thank you!

Victor Font answered 12 months ago
I use browser local storage for search criteria persistence. See this form: You can toggle persistence on and off. Examine how local storage works on the storage tab of your browser's inspection tool. All the source code is on the page. Copy it and use it if you'd like.
Larry Kolinek replied 12 months ago

thanks Victor, but Chris's suggestion did the trick 🙂

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community