I don't have any code samples lying around. Generally, you would create a <ul> for the top-level menu, then have nested <ul>'s for the sub-menus. The CSS styling for the sub-menus would include display:none. Then you would have onclick attributes in the top-level elements to toggle the display status via the JavaScript "style" attribute.
If that's all gobbledy-gook to you, then it might be time to Google for things like "JavaScript hierarchical menus" and such, and see if you can find some ready-made code you can use.