How to customize options of a select field based on other field

I made a web form of a custom doctype and there are two fields, so based on a field value the options of other field should be displayed
ie., there are two fields called Department, Branch
so the options of Branch should be based on value of Department field value

Hi, you can check the link and dynamic link field type for this
https://docs.erpnext.com/docs/user/manual/en/field-types