Hey guys, I am trying to set up a list of links for a list of products in my sidebar, where a user clicks on one category then a sub set of links will appear under the main list link, clicking on any other category closes the previous set of links and opens the new sub set. I tried to do this with PHP but due to using PHP include for my sidebar I ended up with multiple PHP files, not good.I also think that creating this function should be client side, I hope I am right. I do not even know if this could be done in JavaScript, any suggestion on this would be appreciated!

I don't know how to write JavaScript to work with the sidebar.php file which I am including for every page in the sidebar div in the HTML, its really confusing me.

Many thanks!!