Method Community

 

Multiple drop downs that effect each others selection

Last post 01-14-2014 4:20 PM by Anonymous. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-10-2014 12:21 AM

    Multiple drop downs that effect each others selection

    I want to create a category dropdown and a subcategory dropdown.

    When I select a category, the subcategory should change.

    The category dropdown should draw from a new table which has two fields Category and SubCategory.

    The Subcategory dropdown should draw it's data from the same table but of course using the Category selection as a filter to build the data on the fly. 

    How can I set all this up using custom screens?

  • 01-10-2014 12:46 PM In reply to

    Re: Multiple drop downs that effect each others selection

    Hi CF_Pro,

    Am I correct that you are attempting to create a custom screen thatafter selecting the initial Category Dropdown, you want a second, subCategory dropdown, that would list info specific to the first selection?

    If this is the case, I can suggest a slight trick that I would do to accomplish this.  Let's say I have a Category dropdown with 4 options, I would create 4 secondary SubCategory dropdowns, each pertaining to one of the main Categories.  Then, I would use some "conditional statements" so after the main Category option has been selected, you would show/hide the appropriate subCategory dropdown.  

    I will attempt a simple example of what I mean, let's use the theme "Sports".  I would create a dropdown to select a Sports League, then have a sub-category listing of all available teams in the specific league selected in the intial Category Dropdown.  Let's say I included NBA, NHL, NFL, ATP, and PGA.  I will then create a SubCategory dropdown for each league, containing all the sports teams for that league.  The conditional statement would say, ok, if the "NBA" Category was selected, "Show" the SubCategory dropdown that contains all the NBA teams (Raptors, Bulls, Knicks, etc....).  At the same time, the conditional statement will also say hide all other subCategory dropdown fields.

    I hope this helps, I can definitely expand on this if this is what you are attempting to do, but this hopefully this will give you some guidance how to set this up.

    -Ben

  • 01-11-2014 2:07 AM In reply to

    Re: Multiple drop downs that effect each others selection

    Ben,

    After messing around a while I got it to work.  What I did is I created a table called categories, and made 2 fields. Category & SubCategory.

    Something like this

    CategoryName SubCategory
    Restaurants
    Automotive
    Restaurants Pizza
    Restaurants Chinese
    Restaurants Steak House
    Restaurants Japanese
    Automotive Smog
    Automotive Repair

    In the custom screen, made two dropdown fields, one called Category, then other Subcategory

    On the category, I have it loading this table using the categoryname field, I added a filter that says SubCategory not empty.

    Then on the 2nd field, I have it loading this table using the SubCategory field, and I also added a filter that says CategoryName (text) Equal to Value from Screen Category.

    Now the subcategory dropdown fetches the subcategory value in real time based on what the category is equal to.

    -CF_Pro

  • 01-11-2014 3:25 PM In reply to

    Re: Multiple drop downs that effect each others selection

    Ben,

    When I add values to these drop downs, they do not save to the table.  These we're objects that do not have any ties to the DB.  How do I now save the values to the DB. I have a field called Category and SubCategory.  I tried this action but it did not work


    Text Change Action: Update Field in Table

    Update Table:Customer

    Update Field:Category

    Value From: Value From Screen ->Category

    Dropdown Attribute: Text

    Criteria Where the field: RecordID = Value From Session (Current-Screen Active RecordID)

  • 01-13-2014 9:29 AM In reply to

    Re: Multiple drop downs that effect each others selection

    CF_Pro, I am glad you were able to figure out the first part to your scenario, I guess I slightly missunderstood what you were trying to accomplish.

    In regards to your latest post here, I still have some issues picturing what you are doing at this point, which makes it hard to answer your question. For your Category and SubCategory fields, are they dropdowns from your Customer table?  If so, after selecting a value, for testing purposes, you could add a Category and SubCategory text fields to your screen to your Customer table, then also add them to the screen (you can make them hidden, as it really doesn't matter if they are on the screen).  Make it so, as soon as you select your "Category" and "SubCategory", it will take this value and add it to these two fields.  This way, when you press a "save" button this screen, or more specifically do a "Save all sections" action, these two text fields will get saved, and added to the record.  I hope this helps.

    -Ben

  • 01-14-2014 10:14 AM In reply to

    Re: Multiple drop downs that effect each others selection

    Ben,

    That will take care of saving the data to the database, but how do you show the data when you come back to that record, if the fields that store the data are hidden?

  • 01-14-2014 10:26 AM In reply to

    Re: Multiple drop downs that effect each others selection

    Ben,

    Nevermind, I simply created an action onload to copy the saved fields back into the object.

    Works great!

    Thanks

  • 01-14-2014 4:20 PM In reply to

    Re: Multiple drop downs that effect each others selection

    Hi CF_Pro,

    First of all, i am glad you were able to get this figured out.  In regards to the hidden fields I mentioned, you are correct with your response, again I wasn't completely sure how you were using this info so yes, if you reload the screen, if the fields are hidden, this wouldn't be very useful.  I guess I was thinking depending how you have setup your dropdowns, the value might stick in here, but unhidding the two fields makes the most sense.

    -Ben 

Page 1 of 1 (8 items)