Dependent Dropdown

This JS work is taking longer that I thought. The problem has become a little complex. 
Things done:
Dependent Dropdowns are created on selecting different categories.
Working on the select button which will be used to select category out of all dependent dropdown.
Still to be done: Load Products according to the selected category