How to show available fields for a doctype in 'Select' fieldtype?

I have a doctype with 2 fields:

  1. Document Type (document_type)
  2. Field Name (field_name)

What I want to do is when I select document in document_type field, in the field_name type field it should populate the Select options with all the fields available for that doctype.