Preventing loosing change

is ther an option to warn a user that he has to save data of his form before leaving in case he has modified some field ?
Actually, if the user forget to click the save button, all changes are lost when leavin the page and no message is shown indicating that he has made change.



Since the input of the screen is done on the client side (The browser) the main php application is unaware of that. So I think it should be possible, but you have to dive into the Javascript world. I guess that if you use Ajax onchange events you could achieve something similar so I would try this with a small screen of three fields or so. But this is not behaviour out of the box.

This is an old Thread. we are waiting for that.

Thanks for the responses.
@alvagar so you have no news on that ??
Saw that your request is from 2013 !
These kind of thing is an essential feature in my opinion…
They don’t seem to react quickly at scriptcase.

My solution to alert the user when data is not saved:

Add this in onApplicationInit event of the form:
echo “<script>var Haschanged = 0; window.addEventListener(‘beforeunload’, function( event ) {if(Haschanged == 1) event.returnValue = ‘Message to display when leaving’;});</script>”;

Add javascript for Form->OnSubmit so there will be no prompt if the record is saved:
function sc_form_onsubmit()
Haschanged = 0;

For every field that you want to “monitor” add javascript Field->OnChange
function sc_MyField_onchange()
Haschanged = 1;

You will now get an option to leave or stay on the page if any of the “monitored” fields has changed…

@ HakLin0816

Will see because on my form, there’s more than 100 fields, so binding an onChange event on each will be fastidious.

Thanks for your response


Good … Like +1

One can expand browser compatibility by changing OnApplicationInit code like this:

//Close PHP
var Haschanged = 0; 
 window.addEventListener('beforeunload', function( event ) {if(Haschanged == 1) event.returnValue = 'Message to display when leaving';});
 window.attachEvent('beforeunload', function( event ) {if(Haschanged == 1) event.returnValue = 'Message to display when leaving';});
//Reopen PHP

thanks for your hints.
I’m not a programmer and I got some difficult to understand the script.
I inserted all things as you suggested but I got still an error that I don’t know how to fix.
Parse error: syntax error, unexpected ‘?’ in C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\app\Pipeline_Management\form_pipeline_entry\form_pipeline_entry_apl.php on line 619

This is the edit of file code
$_SESSION[‘scriptcase’][‘form_pipeline_entry’][‘contr_erro’] = ‘on’;
echo ??;
$_SESSION[‘scriptcase’][‘form_pipeline_entry’][‘contr_erro’] = ‘off’;

Can you help me on fixing it ?

I changed OnApplicaionInit content also with the code of [HakLin0816] . No errors but nothing happens when I leave the form.

Have you tried to set at TRUE the flag Notify discarded changes in the Layout and Behavior section of the form settings.

yes I did it. Still no warnings …

The previous button content to leave the form is this one but I don’t think it’s wrong.
It a simple redir

if (’[glo_limited_view]’==“Y”)