We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11858
    • 130 Posts
    I am using formIt to create resources ( Thanks To Bruno17s great post here http://modxcms.com/forums/index.php/topic,54204.0.html ) and I would like people to create the resource in the correct folder. To do this, I was thinking I would need several select dropdowns:

    Continent (Asia, Europe, etc)
    Country (UK, France, etc)
    Region (London, South East, etc)

    my site tree looks like this:
    +---Americas
    +---Oceania
    +---Asia
    +---Europe (etc)
    +---France
    +---Denmark
    +---UK (etc)
    +---Midlands
    +---London
    +---South East (etc)


    So the last level (Midlands, London, South East) is the level I’m interested in where people can add records. All I need is the ID of the parent. How can I create a dynamic select dropdown box that pulls the values from the site structure (using ditto or getResources) and populate the select dropdowns?

    I have this working with a simple dropdown using Ditto but it only goes one level. I have seen some tutorials where I could create a load of arrays but it seems inefficient. Hoping someone might have some ideas out there?
      • 11858
      • 130 Posts
      Does anyone have any clues on this? There is a similar post here... but the final solution isn’t dynamic.

      http://modxcms.com/forums/index.php?topic=27481.0

      Cheers
        • 4172
        • 5,888 Posts
        are you looking for something like that?
        http://www.bitrepository.com/apps/viewDemo/?originalPost=http://www.bitrepository.com/dynamic-dependant-dropdown-list-us-states-counties.html&demoPage=http://www.bitrepository.com/demo/dynamic-dependent-dropdown-list/

        [Edit]
        Perhaps a better example:
        http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 11858
          • 130 Posts
          Thanks for your reply Bruno17. They’re pretty much what I’m looking for, but I need to go to 3 levels. Also, I have no clue how to incorporate this into formIt.

          They all seem to rotate around adding a "parentIDs" to child resources, which indicate which items are a child of other items. This is already in the MODx document tree so I should be able to do this with http://api.modxcms.com/modx/modX.html#getParentIds dynamically but I’m still a beginner with PHP.

          I almost want to run subsequent ditto calls to populate the selectbox using the id of the previous selection as &parents, and then when at the 3rd level pass that ID to formIt. But of course that’s my simplistic view of things!

          I bought the database example on the first link you sent, I’ll pull both examples apart and see if I can come up with a solution.

            • 11858
            • 130 Posts
            Another way this could be done could be like http://www.gumtree.com/add_posting.html where the category is chosen first, without any ajax and then pass the parent ID required to the form on another page. Can anyone put me on the right track to create a category selector like above?