MozillaZine

Refresh retains form values - useful or troublesome?

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
antic
 
Posts: 646
Joined: December 12th, 2004, 8:40 am
Location: Oz

Post Posted October 2nd, 2006, 2:41 am

If I may direct people to this thread instead of repeating the post:

http://forums.mozillazine.org/viewtopic.php?t=470263

I was told to ask here about this issue. Basically, the behaviour FF has of "remembering" form values after hitting refresh seems to interfere with DHTML apps that need to keep DHTML manipulations on the page "in sync" with hidden field values that are modified at the same time.

When the user hits "refresh", the DHTML is reset (e.g. element visibility) but hidden form fields keep values that were set in Javascript which, after the refresh, are no longer in sync with how the page looks. I hope I've explained that well enough.

Any ideas how to get around this? I've implemented a javascript function which resets all hidden form fields on page load, to get around someone hitting refresh - is that the only solution?

The whole thing about FF remembering form values, including hidden ones, isn't very friendly to DHTML apps. :( I've suggested implementing a new FORM attribute called RETAINVALUES which could be set to "NO", to overcome this issue without having to resort to special javascript to reset everything.

AlfonsoML
 
Posts: 368
Joined: September 6th, 2006, 1:39 pm

Post Posted October 2nd, 2006, 6:48 am

manually you can do Ctrl+Refresh, but as I said that's manually.
on the other hand you can try to use autocomplete=off in the hidden inputs, IIRC that should work.

antic
 
Posts: 646
Joined: December 12th, 2004, 8:40 am
Location: Oz

Post Posted October 2nd, 2006, 7:45 am

Aitan, many thanks, however this is more an <b>end-user</b> issue - that is, a non-technical person using the online app. If I wanted to use my own app, that setting/technique would be ok, however the problem is how to make it foolproof for the average user.

AlfonsoML
 
Posts: 368
Joined: September 6th, 2006, 1:39 pm

Post Posted October 2nd, 2006, 10:50 am

Please, could you explain what do you want?
I've given you a solution as an end-user and also as a programmer, if none of those answers are useful to you, then I don't understand what you need.

You seem to suggest a new attribute (that idea will never be accepted), but I have show you the actual attribute that does the job now. Or you could change the code so instead of using hidden inputs you just use javascript variables to keep track of javascript changes.

Robin_reala

User avatar
 
Posts: 1344
Joined: September 7th, 2003, 1:21 pm
Location: Guildford, UK

Post Posted October 2nd, 2006, 11:51 am

Would this not be a case for using cache directives in the HTTP headers?

antic
 
Posts: 646
Joined: December 12th, 2004, 8:40 am
Location: Oz

Post Posted October 2nd, 2006, 9:49 pm

Hi Robin. I wasn't aware that cache directives stop FF from remembering form values after hitting refresh. If that's the case, it's a good solution, thanks heaps. I'll check to see if that works.

Aitan, sorry for any confusion, but perhaps read the original post I linked to above, it explains the problem in detail. Using ctrl-refresh or turning autocomplete=off isn't really an end-user solution - they aren't going to know or care to do that just to use a web page.

Your idea of using JS variables instead of hidden fields is appreciated but hidden fields still need to be used. For example, while javascript will visibly remove a row from a table, a hidden field must still be used to tell the server code to delete that row from the database. When refresh is hit, the page *visibly* resets itself (i.e. "deleted" table rows reappear), but hidden field values are not reset. Hence a row's hidden value could still say it should be deleted yet the row is now visible on the screen (implying it won't be deleted). That's the problem in a nutshell, not sure how else I can explain it. :)

Robin_reala

User avatar
 
Posts: 1344
Joined: September 7th, 2003, 1:21 pm
Location: Guildford, UK

Post Posted October 3rd, 2006, 2:37 am

Antic - I don't actually know if that's the case but the form control caching is part of bfcache, so you might want to have a look at http://developer.mozilla.org/en/docs/Using_Firefox_1.5_caching

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: No registered users and 3 guests