Fetch value from table in the same DocType

I need to fetch an specific row fom a table in the same DocType,
I read this https://discuss.frappe.io/t/custom-script-fetch-data/7462/2
But I couldnt do anything.

In salary slip I need get the name and amount of an specific component in earnings, selecting it though client side script by the name of the component.

and put the amount in a custom field in the same doctype.

Is there any way to do that?

Can you share your script what do have done so far so that we can take a look and try to correct it?