Announcement

Collapse
No announcement yet.

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

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    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");
    }

    Comment


    • #3
      Oh. Of course! Manu thanks

      Comment


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

        Comment


        • #5
          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?

          Comment


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

            Comment


            • #7
              session time = max_execution_time? In my case 300

              Comment


              • #8
                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.

                Comment


                • #9
                  any suggestions?

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      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

                      Comment

                      Working...
                      X