Dependent customfield select first possible value


I have 2 dependent Custom fields and I need to force secondary field to
always select first possible value based on category by master field
Now when I change primary selection dependent custom fields selects “no
value” and desired value is shown, but not selected.

tried with some callbacks and scrips without success. I can’t found only
possible values for the field, I just get all values in my program.

Ajax method will be perfect, but it’s possible to set desired value also
after Save button click.

Could you help me, please?