Process of making an entry in any other existing doc type using a custom script

I am very new to erpnext guys please help me out.
I have employee doc type, where I have one section, induction fee charges, in that section, I have 3 fields, i.e. induction total fees, initial payment, remaining payment, and a button called “apply for loan”.
so I want that when a user clicks the button “apply for loan”, the entry must with all applicant details must be made directly to the loan doc type file using a custom script.

Please see my code as mentioned below: I would appreciate your response, to help me with the process, so that I can achieve this from my code