Looking for easiest way to determine if ANY of the elements in page was edited prior to unload of page
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   neal_ravindran
Posted On:   Friday, August 12, 2005 05:48 PM

I have a bunch of tabbed pages each with its own save button. If an user edits a field on a tabbed page and forgets to save the change before going off of that tab into another tab, I want to alert the user that he made changes and would he like to save (a la javascript confirmation would popup and do the necessary, ideally) In the past I have done this by using a global variable and whenever an onchange for an element occured the global variable was updated and onbeforeunload I checked if the global variable value was changed from time of load and popped an alert. This is pretty ugly as you have to stick the onchange handler in every html element on page (the job of onchange handler being to update the global variable) Is    More>>

I have a bunch of tabbed pages each with its own save button. If an user edits a field on a tabbed page and forgets to save the change before going off of that tab into another tab, I want to alert the user that he made changes and would he like to save (a la javascript confirmation would popup and do the necessary, ideally)



In the past I have done this by using a global variable and whenever an onchange for an element occured the global variable was updated and onbeforeunload I checked if the global variable value was changed from time of load and popped an alert. This is pretty ugly as you have to stick the onchange handler in every html element on page (the job of onchange handler being to update the global variable)


Is there an easier way to accomplish this?
(can ajax help me here without placing onchange handlers in every html element in code?)

   <<Less

Re: Looking for easiest way to determine if ANY of the elements in page was edited prior to unload of page

Posted By:   Almagest_FUTT  
Posted On:   Monday, August 15, 2005 10:08 AM

Hi. I prefer the good ol' handcraft, so i'd suggest this javascript block:










About | Sitemap | Contact