It was really just a stub. A working example could look something like the following.
In the JS tab:
var submenus = ['cars', 'planes', 'ships'];
var menudependencies = [
[],
['cars'],
['planes'],
['planes', 'ships']
];
function showHideSubmenus(index) {
// Hide the sub menus.
for (var h in submenus) {
document.getElementById(submenus[h]).style.display = 'none';
}
// Show the selected sub menus.
for (var s in menudependencies[index]) {
document.getElementById(menudependencies[index][s]).style.display = 'block';
}
}
The submenus is a list of element ids of div wrappers for the fields in the add template. The idea is to wrap the field pattern with an identified container element. In the template it would be something like: <div id="cars">[ [Cars] ]</div>. Then for hide/show we don't need to worry about the actual id of the field element and simply hide/show the wrapper. This also allow us to put most of the javascript in the JS tab rather than in the template.
The list of menu dependencies simply defines for each index of the main menu which sub menus should be displayed.
The showHideSubmenus is the event handler. It first hides all the submenus and then shows only those which are defined in the dependencies for the given index.
All the sub menus are hidden by default via css in the CSS tab.
#cars, #planes, #ships { display: none; }
In the add template we assign the event handler to the onchange event of the main menu. We also call the eventhandler directly so that an existing selection would be applied when opening the entry for editing.
<script>
// Set the onchange event of the category menu.
var category = document.getElementById('Categories#id');
category.onchange = function() {showHideSubmenus(this.selectedIndex);};
showHideSubmenus(category.selectedIndex);
</script>
The approach hiding/showing wrappers rather than specific fields can have an interesting application. If you have an entry with many fields that are organized in sections, you can use a menu field to show one section at a time, and make the entering of content more manageable.