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.

Use Conditional Logic on Dynamically Populated Field

  1. I have a drop down that I populate dynamically. What I would like to do is set some conditional logic based on the chosen item in the drop down. The problem is I can't use the normal conditional logic since the field is populated dynamically.

    So I was wondering if there was someone to manually create the conditional logic after the field has been dynamically populated? The drop down populates with event names and the value of each is a date. What I want to do is show or hide fields based on that date. This would be easy enough if the field was manually created in the backend, but the dynamic population is making this harder then it should be.

    What I have done now is wrote some custom javascript to get the value of the drop down and add or remove classes on other field items, in order to show or hide them. This works but it would be nicer to keep it all in gravity forms.

    Posted 12 years ago on Wednesday January 25, 2012 | Permalink
  2. Hi, newhorn,

    You can use the "gform_admin_pre_render" hook (http://www.gravityhelp.com/documentation/page/Gform_admin_pre_render) to populate the admin too. That way you will have your options available for use with conditional logic.

    Posted 12 years ago on Wednesday February 8, 2012 | Permalink
  3. I'm not sure about how/where to use gform_admin_pre_render. My form is at http://gwa.thewildlifefilmschool.com/contact-us/. I want it so that depending on which link a user clicks it populates the first question (ie http://gwa.thewildlifefilmschool.com/contact-us/?formtype=subscribe). Using conditional logic to show specific fields depending on which field is ticked. They user can then tick additional boxes if needed to show more fields. Help!

    Posted 12 years ago on Monday April 2, 2012 | Permalink
  4. Hi, anndonnelly,

    Your question is different from what the other user was asking. It is best for you to post your own topic in the future, especially since this is an old post that I wasn't actively checking.

    For the checkbox that you are trying to check based on what link was clicked upon, you should use the querystring parameter. Go to the Advanced tab for your checkbox field in the admin and check the "Allow field to be populated dynamically" option. When you check that option off a text box will appear called "Parameter name". This is where you would put the name of your querystring parameter. In your example, you appear to be passing the parameter as formtype, so you would use that.

    If you want fields to display depending on what link was clicked, you can add conditional logic to those fields in the admin on the Advanced tab and key those off of your checkbox field. If I am understanding you correctly, you should be able to do all this without custom code and without using any Gravity Forms hooks; do it all in the admin.

    Posted 12 years ago on Wednesday April 4, 2012 | Permalink

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