Submit form and redirect only when buuton "update" is pressed

Hi There,

I have a form with the following script in java to autosave the users input

function sc_form_onload()
{
setInterval(function(){
nm_atualiza (‘alterar’);
}, 300000);
}

and the following script to redirect users after the update the form manulay

OnVallidate OR on OnAfterUpdate
/*

  • opslaan en redirect naar pagina met refresh
    */
    sc_commit_trans()

sc_redir(‘W_event_menu_organisatie.php’, ev_id=[ev_id];, “_parent”);

Work like a charm.

but when the autosave kicks in the user is automatically redirected to the page above. i would like the redirect only happened when the user hits the button.

any suggestions?

I think you can test in event OnValidateSuccess:
if (sc_btn_update)
{
sc_commit_trans()
sc_redir(‘W_event_menu_organisatie.php’, ev_id=[ev_id];, “_parent”);
}

Oh. Of course! Manu thanks

Is there a way in scriptcase tot change the events for multiple forms at once?

@rotrax

I tried your code in the java section.I just changed the interval to 20000. But i my case the function stops after some time. It runs 2 or 3 times and stops.

Any idea why?

did you deploy it. the first time in Dev i didn’t work at all. also take a look at your session time

session time = max_execution_time? In my case 300

Strange, when i use the suggestion above

if (sc_btn_update)
{
sc_commit_trans()
sc_redir(‘W_event_menu_organisatie.php’, ev_id=[ev_id];, “_parent”);
}

then the code just kicks in when the javascript launches. even when the button is not pressed.

any suggestions?

if the code is correct the semicolon after ev_id = [ev_id] must certainly cause a fault, so the procedure on update runs, but stops at the semicolon

When the if statement is deleted the script works fine. it just that it alwys works even when the button is not pressed.

i think the problem is in the javascript

function sc_form_onload()
{
setInterval(function(){
nm_atualiza (‘alterar’);
}, 300000);
}

for some reason the above is interpreted as a button press