Blog

Read and auto populate fields in WordPress Gravity forms with jQuery

Hello!

When designing and implementing Gravity forms there may be occasions where you would want to auto populate multiple fields based on a preceding field selection. This was the case in our scenario where we wanted to populate the selection of a drop-down box based on a Google Map location field within Gravity Forms on WordPress.

What we wanted was for the person to enter their location in a Google Map location field (within gravity forms) and based on that selection, read the respective City within that location and based on that selection, populate a drop-down box. Gravity forms already possesses the ability to implement conditional logic, however it largely is designed for the purpose of revealing/hiding/activating input elements based on preceding choices. We need to actually inject an input selection

I’ll try to walk through the process to implementing this type of logic specifically with Gravity Forms.

Get the Gravity Form field ID that you want to capture with jQuery

Lets say that you want to capture the value of an input field. Before we go into the jQuery to accomplish that, we need to be able to identify which field we want to capture.

There’s two ways to grab the ID. The first way you can edit the Gravity form in question and look at the field ID. If your form ID is “2” and your field id is “6”, then the input id is “#input_2_6”.

The other way is to simply inspect element of the input field and look at the ID of said field.

Use jQuery to capture the value of the input field after someone has entered the value

Grabbing the value of an input field is relatively straightforward. But what about waiting until someone enters the value? You have to be able to let jQuery “discover” the field value after it has been entered.

What we want to do is load a few lines of jQuery on the page where the form is located. This can be done in WordPress or by implementing a custom page template in the wordpress theme and then assigning it to this page.


    
    

At Shift8, we cater to all sorts of businesses in and around Toronto from small, medium, large and enterprise projects. We are comfortable adapting to your existing processes and try our best to compliment communication and collaboration to the point where every step of the way is as efficient as possible.

Our projects are typically broken into 5 or 6 key “milestones” which focus heavily on the design collaboration in the early stages. We mock-up any interactive or unique page within your new website so that you get a clear picture of exactly how your design vision will be translated into a functional website.

Using tools like Basecamp and Redpen, we try to make the process simple yet fun and effective. We will revise your vision as many times as necessary until you are 100% happy, before moving to the functional, content integration and development phases of the project.

For the projects that are more development heavy, we make sure a considerable amount of effort is spent in the preliminary stages of project planning. We strongly believe that full transparency with a project development plan ensures that expectations are met on both sides between us and the client. We want to ensure that the project is broken into intelligent phases with accurate budgetary and timeline breakdowns.

Approved design mock-ups get translated into a browse-ready project site where we revise again and again until you are satisfied. Client satisfaction is our lifeblood and main motivation. We aren’t happy until you are.

Need Web Design?

Fill out the form to get a free consultation.


Shift8 Web Toronto – 416-479-0685
203A-116 Geary Ave. Toronto, On M6H 4H1, Canada
© 2024. All Rights Reserved By Star Dot Hosting Inc.
Contact Us
Phone: 416-479-0685
Toll Free: 1-866-932-9083 (Press 1)
Email: Sales@Shift8web.Com