Jump to content

Wait for calculated fields before submitting a form.


Recommended Posts

Hello,

I have a submission DataPage with some calculated fields that require some time to finish the calculation and I need a way to set a delay of about 30 seconds after the user clicks the submit button.

I found something similar in a tech tip from Caspio to set a timeout to the form but that's not exactly what I want to achieve.

Can anyone help me with this please?

Link to comment
Share on other sites

Hi @Barry

Although there is no standard way to do this in Caspio, a simple JavaScript could do the job:

    window.addEventListener('load', function () {
      // Get all elements with IDs starting with "Submit_"
      var submitElements = document.querySelectorAll('[id^="Submit_"]');

      // Disable each element for 30 seconds
      submitElements.forEach(function (element) {
        element.disabled = true;
      });

      // Enable elements after 30 seconds
      setTimeout(function () {
        submitElements.forEach(function (element) {
          element.disabled = false;
        });
      }, 30000); // 30 seconds in milliseconds
    });

You can see comments so that you can adjust each part to your needs. Also, I have attached a sample app where I applied the code.

However, my solution may not be perfect since the button looks active, it just allows the submission after the time interval. 

If you need it to be 'visually' inactive, you may also need to apply some CSS.

FORUM_Make_Submit_Button_Inactive_for_First_30_1_0_2023-Nov-23_1014.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...