PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Predictive field - Ajax

  1. remotecontroldesign
    Member

    Hi Guys,

    I would like to make a form that has a predictive field, similar to what is used on the title field on the forum post. Basically I want to have a list of stores stored and if someone starts typing "Walmart" and it already exists then I would like it to show and and you can select it.

    Any help would be great!

    Posted 13 years ago on Friday January 21, 2011 | Permalink
  2. Hi there, since a Gravity Form outputs just like any other form, you an apply a jQuery autocomplete plugin to whichever field you'd like:

    http://www.devbridge.com/projects/autocomplete/jquery/

    There are two primary ways of populating the list of values used to query this database:

    1. Ajax, which would run a function that queries the database and returns a list of suggest values
    2. Manual PHP, when the form is loaded you run a PHP function that queries the database once for a list of all the current values and then the script would use this list of values to populate the suggested values rather than an ajax search every time.

    Both options require a bit of knowledge of PHP and Javascript, so if you are not familiar with either, you might want to consider hiring a developer to assist with this.

    Posted 13 years ago on Friday January 21, 2011 | Permalink
  3. remotecontroldesign
    Member

    Ok thanks for the tip, I should be able to work it out.

    How would you recommend to store the store names, under a category or as a custom field?

    Posted 13 years ago on Saturday January 22, 2011 | Permalink
  4. If the list of stores will be a static list, it might be simplest to just hard code it into the "lookup" property of the ajax script above.

    If the store names should be based on previously entered submissions and you are familiar with PHP, I would recommend querying the Gravity Form database to retrieve the previously submitted store names.

    Posted 13 years ago on Sunday January 23, 2011 | Permalink
  5. greentypewriter
    Member

    I'm also trying to autocomplete fields and i'm new to jquery. I just don't know know where to add the code. Would it go into my WP theme code or into GF code? (Sorry if this is a dumb question)

    Posted 13 years ago on Monday February 21, 2011 | Permalink
  6. It would go in your WordPress theme, in the theme template for the template that is used to display the form. Never edit Gravity Forms code, it makes upgrading difficult. Customizations are always designed to be added to your theme or child theme if using a framework, which won't impact Gravity Forms upgrades.

    Posted 13 years ago on Monday February 21, 2011 | Permalink
  7. You can use jQuery UI too http://jqueryui.com/demos/autocomplete/ or http://code.drewwilson.com/entry/autosuggest-jquery-plugin

    Posted 13 years ago on Saturday May 14, 2011 | Permalink

This topic has been resolved and has been closed to new replies.