1 2 Previous Next 20 Replies Latest reply on Nov 15, 2007 10:43 PM by Earl Lewis

    Page Validation - dirty form - Ask to save

    180069
      We are using Tab forms. we want to make sure that the use saves the work in the first form before moving to the then next tab. Any way to check if the data was changed or if it is a new record that it has been saved?
        • 1. Re: Page Validation - dirty form - Ask to save
          Dimitri Gielis
          Interesting question...

          My first thought was to put javascript in your form or in the tab... but the form is not an option, as the tabs are independent. So javascript in the tabs? when I select a tab I can't really influence that behaviour (change it so it runs javascript instead of going to a page).

          What maybe can work for you, is to change your template. In the Tab Attributes you should put some code (probably javascript) that runs first to check if there was a change.

          I also thought about Application Processes or Application Computations as that can run on every submit of a page. Application Computation can maybe work, you can have a look into that too...

          Dimitri
          • 2. Re: Page Validation - dirty form - Ask to save
            369783
            Sure you can.

            It will depend on which kind of forms on exactly how to do this, but in the help section, under API's, check out the MD5 functions.

            Basically you'd want to comapre the DM5 value of the form data versus the MD5 value of the same records in the database (from a select statement). If they're the same, no data change, if there different, commit the change and move on.

            Bill Ferguson
            • 3. Re: Page Validation - dirty form - Ask to save
              partlycloudy
              See the example and the referenced forum link at http://apex.oracle.com/pls/otn/f?p=24317:54
              • 4. Re: Page Validation - dirty form - Ask to save
                Dimitri Gielis
                Ah, apparently I misread the question...
                I thought the initial poster was talking about clicking on the navigation tabs...

                Dimitri
                • 5. Re: Page Validation - dirty form - Ask to save
                  506791
                  Me and scott are working on the same project.


                  Your absolutely right dimitri. it's about Tabs. Forms within tabs. The user will enter the information on the first tab and then move to the next tab for another form. we need away to alert the user of saving information before moving to the next tab if the information is updated or a new record added.
                  we were able to alert (message box) the user whenever he moves from one tab to another, by adding the following code in the non current standard tab area

                  [td][a href="javascript:if (confirm('You are about to leave this page.'+'\n'+
                  'Current data will be saved.'+'\n'+
                  'Do you wish to continue?'
                  )) { doSubmit('T_#TAB_LABEL#')}" onmouseover="status='Goto This Tab'; return true;"

                  onmouseout="status='';"]#TAB_LABEL#[a]
                  [td]

                  of course replacing [] with <>

                  But this is a bad solution, the user will be alerted every time he navigate from one tab to another. We want to alert the users only when they modify the form or create new records . User enter information on the first tab form, and then if the user make any changes to the data of the first form we want to alert for saving the record before moving to the next tab. Vikas solution is great and works for pagination, but that's not our intention, we want this to work navigating tabs when modifying data or creating new records in forms within tabs.

                  Please Help,
                  Thanks,
                  Mhnd.

                  Message was edited by:
                  Mhnd
                  • 6. Re: Page Validation - dirty form - Ask to save
                    partlycloudy
                    and works for pagination

                    My solution is a generic solution that uses the onBeforeUnload event to check and warn of unsaved changes to all form items on the page. Regardless of how you navigate away from the page (by clicking on an APEX tab, typing a new URL in the browser, closing the browser, whatever)
                    • 7. Re: Page Validation - dirty form - Ask to save
                      506791
                      Hi Vikas and thanks for your quick response,

                      You posted this in another thread, and I've used your solution earlier before this post.

                      To give yo an idea about the project:

                      we have a Total of fifty different forms spread between 9 different tabs !!.

                      I tried the java scripts you provided with our form layout that has combinations of radiogroup, selectlists, textarea, and text, pickup date, the forms we have contains from 19-30 different elements including ajax lists. When I tested it I noticed the following:

                      -The java scripts works just fine with tabular forms with one exception, pops up twice when selecting save button after the form has been modified.

                      -When I applied the same scripts to the forms we have (Combination of elements), it works when we modify the first text field element on the form, like I said earlier our forms contains multiple elements. If I modify any other element on the form the alert box does not appear at all. It seems that the isformchanged/iselementchanged loops works only when modifying text boxes or combination of text boxes (Tabular forms).
                      I'm I missing something here? Do you have a workaround for this problem?

                      Once again thanks for your advise and quick response.

                      Mhnd.
                      • 8. Re: Page Validation - dirty form - Ask to save
                        partlycloudy
                        pops up twice when selecting save button after the form has been modified

                        Works fine for me in Firefox, must be an IE thing. Can you provide a step-by-step to reproduce?

                        If I modify any other element on the form the alert box does not appear

                        The isFormChanged function looks at all the form INPUT elements and considers the form "dirty" if at least 1 input has changed (value != defaultValue). It is very simple code, take a look at it and see if it is missing any form element types.

                        Again, put up an example where something doesn't work as you expect and we can take a look at it.
                        • 9. Re: Page Validation - dirty form - Ask to save
                          506791
                          Hi Vikas,

                          I did the tabular form and it worked just find like I said earlier, so there is nothing wrong with the procedure I followed.
                          And again it's working on my forms with different elements, but only when changing or updating the first element on the form, located at (0,0). If I change any other element it does not fire at all. .....

                          IE/FF

                          Too bad that IE pops up twice! I will try it in FF.

                          Thanks Again,
                          Mhnd.
                          • 10. Re: Page Validation - dirty form - Ask to save
                            506791
                            Hi,

                            Good News!

                            I implemented the java scripts in the form and it's working great for all element except radio!

                            One more problem we have is when navigating from one tab to another the alert box is firing even when no changes are made to the form, we are in the process of checking this out. I also installed FF, the alert pops out only once (IE 7.0 pops up twice for some reason), business requirement to use IE ....

                            Thanks!
                            • 11. Re: Page Validation - dirty form - Ask to save
                              Earl Lewis
                              Vikas and Mhnd,

                              Sorry to break into this thread but I wanted to ask Vikas if he still had the application builder apps installed/available for perusal somewhere. I did a search and couldn't find the old thread that referenced the location of those. And they aren't linked on your examples page. Did you take them down?

                              Earl
                              • 12. Re: Page Validation - dirty form - Ask to save
                                partlycloudy
                                I still have the Builder apps from 2.0 installed in my workspace but I have disabled the guest login to my workspace.

                                If 2.0 is good enough for you, send me a note at the email address on my homepage (on my OTN profile) and I can set up a login in my workspace for you.
                                • 13. Re: Page Validation - dirty form - Ask to save
                                  524073
                                  Hi,

                                  We have the same problem in our pages, did you find a solution about the alert box which poped up ?, would bee very nice if you have any information

                                  best regards

                                  jon.
                                  • 14. Re: Page Validation - dirty form - Ask to save
                                    588772
                                    Hi,

                                    I am having a similar issue with the tab navigation.

                                    There are 3 tab buttons and each button has one form page. When the user enters some data in form 1 in tab 1 and leaves to another form 2 through tab 2 the previous forms filled data is lost. So, I want to give an alert save message to the user when they try to go to another form by clicking the tab.

                                    I could get the message for Delete button but unable to solve this tab issue.

                                    Any help is highly appreciated.

                                    Thanks,
                                    Shetty.
                                    1 2 Previous Next