Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ibookin'

macrumors 65816
Original poster
Jul 7, 2002
1,164
0
Los Angeles, CA
I have a problem that's bugging me a lot. I have a form with over 200 fields, and today when someone was filling it out they somehow managed to refresh the page accidentally and all the entries were lost. Is there any way, either in the browser or in the code (I am using PHP 4, connecting to a MySQL database), that I can prevent this?

Thanks for your help.
 
ibookin' said:
I have a problem that's bugging me a lot. I have a form with over 200 fields, and today when someone was filling it out they somehow managed to refresh the page accidentally and all the entries were lost. Is there any way, either in the browser or in the code (I am using PHP 4, connecting to a MySQL database), that I can prevent this?

If they reset the form using a "reset" button then it'd be easy - you'd just have to write a bit of JavaScript, and keep values for each of the form fields stored using "onChange". Then you could add what amounts to a one-level undo button, which would restore the form values based on the stored values.

However I can't, off the top of my head, figure out a way to do this if they refresh the page. "onExit" will let you set an action on page exit; but you don't want to always do an action onExit because most of the time when people leave the page, that's what they really intended to do! :)

Unfortunately there's only so much you can do to protect users from their own mistakes. It's certainly worthwhile to do everything you can reasonably accomplish; but this might be asking a bit too much.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.