There are various aways of doing this - depending on whether you want to submit the page first and then progress, or do it all through javascript after having PHP load the variables into some form of array within the page.
Admittedly, I would recommend loading the page over again - as this would speed up the page load (imagine loads of recursive directories.. that would take ages for javascript to sift through)
All you would do is pass the value of the first select box to the same form, and let it know to display two of the select boxes, and populate the second just like the first.
Obviously you could find some difficulty in that there could (theoretically) be 1000s of nested folders...