Auto-Submit a Form on Page Load Gravity Forms

We have had a couple of requests from Gravity Forms users that wanted to know how to submit a form automatically once the form page loads.

In some cases, they are passing data via a query string and all they need is for that data to populate the form and be submitted.

Use Case Example

One use case I can think of is a simple solution for employees to clock in and out. They log in to their account, click the “clock in” button which is preloaded with a URL and any necessary parameters. I’ve demonstrated this below.

To get this to work you only need an HTML field in your form and the code snippet below.

Setting Up Your Form

You can add whatever fields you’d like to your form, but for this to work, you must have an HTML field with the code below added to the content field.

Below is the code snippet you will need.

To make the code work you will need to make two modifications after pasting it into your HTML field.

  1. Change ID# on line 24 to your forms actual ID number
  2. Change the delay time on line 27, currently set to 500 which is half a second

Additional Code Snippet

If you prefer to not have a delay in your submission and instead have the form submitted as soon as the form renders, you could use the snippet below.

Just be sure to replace ID# with your forms ID number.

<script type="text/javascript">
     jQuery(document).on('gform_post_render', function(){
           jQuery('form#gform_ID#').trigger('submit');
    });
</script>

The Wrap Up

I’m sure there are many other use cases where having the ability to auto-submit a Gravity Forms form is necessary, and if you have one of those cases, hopefully, this solution will work for you!

If you have any questions or need additional assistance, please use the comments below.

0 0 votes
Article Rating
Subscribe
Notify of
guest

10 Comments
Inline Feedbacks
View all comments
Russell
9 days ago

This didn’t work for me for some reason

Russell
Reply to  Chris Eggleston
7 days ago

Hi,

Yeah I tried both and amended the form id. I have some required fields on my form but i expected just to see the rejection message to say the required fields haven;t been completed (as if i had manually clicked the submit)

Norman
Norman
4 months ago

Frickin’ cool!!

My only comment is clarification on the syntax regarding the form ID. Here’s my working code:

Norman
Norman
Reply to  Chris Eggleston
4 months ago

I thought I put it in there — I just replied to my post with the code (again?). In any case, I used the “additional code snippet” from above and used the substitution below. Per the directions above, I literally substituted the characters “ID#” with my form number “10”, resulting in the look below.(Perhaps it was just me, but it wasn’t exactly obvious to me what exactly should be replaced.)

This really is frickin’ cool! Thanks, Chris!

BTW, I’m considering removing the confirmation webpage notification once the form is automatically submitted — I can’t find how to disable or delete the confirmation. Any ideas?

‘form#gform_10’

Norman
Norman
Reply to  Norman
4 months ago

OK, the code doesn’t show when I copy/pasted, please delete this post and edit my original to show my example above if you don’t mind.

Marky
Marky
4 months ago

Thank you for info.

by the way, how to put conditional logic?

For Example, submit button is not shown based on the conditional logic then pause or stop auto-submit.

is there an example can see and try?