|
Posted by Jerry Stuckle on 10/23/07 00:20
The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> The Natural Philosopher wrote:
>>> Fester Bestertester wrote:
>>>> Greetings,
>>>>
>>>> I'm an occasional php/mysql dabbler.
>>>>
>>>> I have a basic data form with a submit button. Unfortunately, it's
>>>> still possible for the user to enter data changes and close the
>>>> window, without clicking the submit button, thus losing the data.
>>>>
>>>> Can someone point me to a generic example of some code that will
>>>> trap and handle this error?
>>> Only way is via javascript.
>>>
>>> Something like "onunload submit".
>>>
>>> But the syntax is far more complex.
>>>
>>> Another way to achieve what you want is to use javascript to submit
>>> the form any time anything changes using teh onchange function.
>>>
>>
>> Terrible advice. What happens if they put in 1/2 of the data they
>> want to update, then have to close because they get called away?
>>
>
> That depends. In some cases that is desirable behaviour, if the fields
> are somewhat independent.
>
> Oherwise an alert box on unloading, and ask them if they want to scrap
> the data they have entered..
>
And if they have a power failure, their internet goes down, their
browser crashes... Now what do they do?
>
>> Or, if it updates on the fly like you suggest, they update one field
>> and the system crashes, the power goes out, the internet connection
>> drops - whatever.
>>
>
> No problem really..it depends if the form comprises an atomic
> transaction. Lots do not.
>
True. Many do not comprise an atomic transaction. So updating only
part of the data is very bad.
>> Someone trying to enter a new address comes to mind. You want all of
>> the changes or none of the changes.
>>
>>
>
> Dunno. Here just changing the postcode woul probably be enough ;-)
>
Is it? What happens if I enter a new street address and the system goes
down? What happens to the city, state, postal code...
> However if you want an atomic transaction, use onchange to set a flag,
> and submit to clear it, and on unload if the flag is still set, issue
> warning.
>
> Its fairly standard javascript.
>
Which does you absolutely no good if you have one of the problems noted
above.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|