Get the name of related field

Good day guys. Thank you for visiting.

After I select a record in the relate field, I need to auto fill another relate field. The problem is, how can I get the name of the 2nd relate field ?

PS. I want to avoid using JS as much as possible.

that ID that I highlighted should be a value of the related input’s hidden field so that it can be submitted. I have already inserted it to the hidden input.