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.

Dynamic dropdown

  1. Hi,
    I'm new here.
    May be my question is similar to http://www.gravityhelp.com/forums/topic/dynamic-ajax-category-child-dropdown, but I may ask a simplest way.

    My problem is easy.

    1 - Dropdown with categories, for example :
    - Database,
    - Language

    2- If user selects "Language"
    He will have :
    - PHP
    - Dot Net

    Cheers

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  2. That example code you linked to is fairly complex.

    How many category drop downs will you have, then how many dependent possibilities are there? And do they change, in other words, are they pulled from your WordPress database, or can they be defined one time and not change?

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  3. Chris, thank you for your quick answer.

    Categories are 20 and change
    Sub-categories are 20 each.
    Categories and sub-categories are both from an extra table (categories and sub_categories).
    They need to be called dynamically (and not defined one time).
    I have seen http://www.gravityhelp.com/forums/topic/dynamic-ajax-category-child-dropdown and it look like what I search...

    Your help is welcome.
    Thank you in advance.
    Cheers

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  4. Having 20+ categories and 20+ sub-categories, plus being populated dynamically, rules out using conditional logic to reveal the choices. The code you linked to is a very good start to do what you need to do, but that is honestly well beyond the support we can provide for Gravity Forms. If you need help implementing that, you might try posting a job on our job board or on any of the WordPress-related job boards out there. http://www.gravityhelp.com/forums/forum/job-board

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  5. Chris,

    Thank you for your answer, I appreciate it.
    I have implemented the source code (http://www.gravityhelp.com/forums/topic/dynamic-ajax-category-child-dropdown).
    Everything works and I'm really happy to use the support forum. May be I will try the job board for more complex project. Thanks for the information.

    I have one little problem and I think you or support forum could help me : Field Validation.
    May be you would take a look at that test page (http://www.cyberworkers.com/test-gravity-form).
    I put the source code and the script himself on that test page.

    Problem description :
    When you select a category (let's say "Programming Language"), dynamically the subcategory dropdown is populated and you got a subcategory dropdown with "PHP, DOT NET, ....".
    Ok for that, it's implemented as you can see on the test page.

    In the subcategory dropdown user must select an option.
    The value for option "Choix" is equal to zero.
    So I add a control like "if($value=="0" $result["is_valid"] = false;)".
    But when GF return the error message, the subcategory dropdown is reseted (and not populated).

    May be there is a code already explain on the forum or a simple solution ?
    Thanks a lot in advance for your help.

    Posted 11 years ago on Wednesday January 16, 2013 | Permalink
  6. Chris, me again, do you need more explanations ? Cheers.

    Posted 11 years ago on Wednesday January 16, 2013 | Permalink
  7. When a validation error occurs, the value of the drop downs is reset when the page is reloaded. This is by design and was required to allow us to have dependent drop downs. I am trying to find a post by Alex Cancado which explains it in more depth, but I believe this is by design.

    Posted 11 years ago on Wednesday January 16, 2013 | Permalink
  8. Chris, thank you for your help. I hope Alex's post could give us a solution.
    May be, I could simply put a simple javascript alert to resolve the problem ?
    If yes, how and where can I put that kind of hook ?
    Thank you for your help.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  9. Hello again Chris, I appreaciate your help, would you please help me to find a solution (I think we have the Alex's solution or the Alert Javascript hook). Best.

    Posted 11 years ago on Sunday January 20, 2013 | Permalink
  10. Hello Chris, any chance to get a solution ?

    Posted 11 years ago on Tuesday January 22, 2013 | Permalink
  11. This is by design and I don't have a work around for you. The post by Alex Cancado was an explanation of why it needs to be this way, but there was no work around there either.

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink