Robert Granlund
asked on
Wordpress empties form fields when refresh page
Wordpress WooCommerce When you fill in form field data and for whatever reason you need to refresh the page, you loose all of your form field data. Is there anyway to override the Core Wordpress Functionality to reload empty fields?
I tried something like this:
Go here and pick either product: http://slideswizard.fireflie.webfactional(DOT)com/pricing/
Go to the checkout page fill in billing or customer notes and then upload a file. It will clear the form field Data
I tried something like this:
window.onload = function() {
// If values are not blank, restore them to the fields
var firstName = sessionStorage.getItem('firstName');
$('#billing_first_name').val(firstName);
var message= sessionStorage.getItem('message');
$('#order_comments').val(message);
}
// Before refreshing the page, save the form data to sessionStorage
window.onbeforeunload = function() {
sessionStorage.setItem("firstName", $('#billing_first_name').val());
sessionStorage.setItem("message", $('#order_comments').val());
}
Go here and pick either product: http://slideswizard.fireflie.webfactional(DOT)com/pricing/
Go to the checkout page fill in billing or customer notes and then upload a file. It will clear the form field Data
ASKER
That did not work.
I basically need to store the Custom Message. If you upload a file, once it has uploaded it clears the form, so any information that a customer enters into the form is lost. It is a pain for the customer.
I basically need to store the Custom Message. If you upload a file, once it has uploaded it clears the form, so any information that a customer enters into the form is lost. It is a pain for the customer.
where exactly is your code located? Right now there is no event attached to window.onbeforeunload...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Basically this will kill your calls to store / load session data.
Solution: replace $ with jQuery, e.g.
Open in new window
P.S. Please never change WP core files :D