[FX.php List] A little JQuery/javascript help

Bob Minteer bob at minteer.org
Fri Aug 31 13:56:46 MDT 2012


Johnathan,

I think you are looking for something like this:

    http://pastebin.com/e0HacSpr

I added a submit handler and a flag that you can set when you have clicked
the save button and have properly saved off the form data.   That should
give you a boost in the right direction.

Regards...

Bob Minteer


On 8/30/12 6:16 PM, "Jonathan Schwartz" <jschwartz at exit445.com> wrote:

> Sorry for the delay.
> 
> I have documented the challenge here:
> 
> http://exit445.com/testform.php
> 
> 
> Jonathan
> 
> At 11:16 AM -0400 8/27/12, Denis Somar wrote:
>> Hi Jonathan,
>> 
>> Put the <form> code in the email also, just to see what we're dealing with
>> here.
>> 
>> D
>> On Sun, Aug 26, 2012 at 7:06 PM, Jonathan Schwartz <jschwartz at exit445.com>
>> wrote:
>>> Hi Folks,
>>> 
>>> I've added a short script to a page to help remind the user to save their
>>> data before leaving a form.  I found the script in a JQuery page, but don't
>>> know how to make a needed modification.
>>> 
>>> It works as needed if the user tries to leave the page. But, it also warns
>>> the user when the Submit button is clicked to save the data. That's one case
>>> where it should not produce a warning.
>>> 
>>> Anyone know how to disarm the script in the single case of when the submit
>>> button is clicked, the javacsript equivalent of
>>> 
>>>        if(!isset($_POST['submit']))...
>>> 
>>> Thanks.
>>> 
>>> JOnathan
>>> 
>>> 
>>> 
>>> <script lanuage="Javascript">
>>> var form_clean;
>>> 
>>> // serialize clean form
>>> $(function() {
>>>     form_clean = $("form").serialize();
>>> });
>>> 
>>> // compare clean and dirty form before leaving
>>> window.onbeforeunload = function (e) {
>>>     var form_dirty = $("form").serialize();
>>>     if(form_clean != form_dirty) {
>>>         return 'There is unsaved Event data.';
>>>     }
>>> };
>>> </script>
>>> --
>>> Jonathan Schwartz
>>> Exit 445 Group
>>> jonathan at exit445.com
>>> http://www.exit445.com
>>> 415-370-5011 <tel:415-370-5011>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>> 
>> 
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20120831/ed92c175/attachment.html


More information about the FX.php_List mailing list