Autocalculate field in a form

Hi All,

I have a form with three field X,Y and Z.

I want to filed Z automatically according to the X and Y values. x and y
option fileds.

eg

if x filed value is “j” and Y field value “m” then Z field value must
filed automatically with “k”.

I would like to do this with onfocus method.