Code for form to take automatic action

Home Forums General discussion Code for form to take automatic action

Viewing 5 reply threads
  • Author
    Posts
    • #28885
      Sebas
      Participant

        Hello,

        I’m trying to determine what code to use on dffs for the form to take the following actions.

        When user clicks on a checkbox from the main tab, I want the form to take the following actions:

        1. Save the changes made to the record
        2. Prompt a pop-up with a question with “yes/no” options (if user selects “no” just close the form)
        3. If user selects “yes” take user to second tab within the same form for the rest of the information to be completed.

        Thanks in advance

      • #28889
        Alexander Bautz
        Keymaster

          Hi,
          Will this be used to in NewForm and if the user selects Yes, redirect to EditForm to continue?

          Alexander

        • #28893
          Sebas
          Participant

            Hi Alex – No. The user would be in edit form (tab 1) and when completing that form and clicking the last checkbox, then the prompt would appear and if user selects yes, it would take him to the next tab (tab 2) also in edit form.

          • #28899
            Alexander Bautz
            Keymaster

              Do you need to save the form first, or just prompt the user if the form should save and exit, or continue to tab #2?

              Alexander

            • #28901
              Sebas
              Participant

                Hi Alex,

                I added a quick mockup to this response. Hopefully that helps.

                Let me know!

              • #28909
                Alexander Bautz
                Keymaster

                  You can use something like the below snippet, but if you actually are in EditForm already you need to use some rules to hide the second tab initially and then show it when you save the form and are redirected.

                  jQuery("#dffs_Acknowledge input").on("click", function() {
                      if (jQuery(this).prop("checked")) {
                          spjs.modal.add({
                              "title": "",
                              "html": "Thank you for completing the form. Will you be willing to fill out a 2 min survey?",
                              "allowMaximize": false,
                              "showClose": false,
                              "resizable": false,
                              "ok": function() {
                                  spjs.dffs.redirect(location.href+"&sTab=1");
                                  spjs.dffs.triggerSave();
                              },
                              "cancel": function() {
                                  spjs.dffs.triggerSave();
                              }
                          });
                      }
                  });

                  Replace “Acknowledge” with the internal name of your Yes/No field.

                  Alexander

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.