Salesforce doesn't reveal information about dependent picklists in normal Describe calls in Apex, but it is included in calls via the API, and can also be accessed through Apex by serializing and deserializing PicklistEntry objects (see gist linked below for an example of how to do that).
Each PicklistEntry in a dependent field has a property called validFor
which contains a Base64 encoded string. When decoded to bits, each bit read left to right corresponds to an option in the controlling field. For example, if you have a validFor
of "gAAA"
example pke.validFor: g A A A
displayed as bits: 100000 000000 000000 000000
rearranged as bytes: 10000000 00000000 00000000
As such, you can use loop through all of the picklist values and use bitwise operators to check whether each dependent value is valid for each controlling value.
I wrote a javascript function and Apex Class to abstract all this, which is available as a gist. You can use it like this (assumes you've correctedly loaded the Ajax toolkit in a visualforce page):
/* Build an Object in which keys are valid options for the controlling field
* and values are lists of valid options for the dependent field.
*/
var OBJ_NAME = 'Custom_Object__c';
var CTRL_FIELD_NAME = "Controlling_Field__c";
var DEP_FIELD_NAME = "Dependent_Field__c";
var options = getDependentOptions(OBJ_NAME, CTRL_FIELD_NAME, DEP_FIELD_NAME);
console.debug(options);