How do I change the value of an option field based on the value of another field from a different table?

I am working on the Sales Invoice page / Sales Header table / Sales Lines table.
I have a custom text field on the Sales Lines, and a custom option field on the Sales Header.

I would like to accomplish the following: Change the value of the option field (on the Sales Header) based on the value inputted on the text field (on the first Sales line item).

For example, if my option members were ‘yes’, ‘no’, and ‘error’. If a user inputs ‘yes’ on the text field, I would like the option field to default to ‘yes’. Similar thing for ‘no’ being inputted. If there is nothing inputted in the text field then ‘error’.

Can I please get some help accomplishing this requirement? I am thinking of making a OnValidate() trigger on the text field but I am not sure how to code this in its entirety.