Cmdbuild - javascript

Hello everyone,
I would like to interactively introduce a value in one field based on the value introduced in another field. Is it possible to do this with javascript? using events?
if so could you give me an example of this?

thanks in advance

You can achieve that using the Auto Value of the field you want changed. Here’s an example of how I did that to calculate the Tax Amount. By binding the attributes TaxableAmount and VATRate changing either would trigger the JavaScript.

api.bind=["TaxableAmount","VATRate"];
var vatRate = Ext.isEmpty(api.getValue("VATRate"))?0:api.getLookupCode("VATRate")*0.01;
api.setValue(api.getValue("TaxableAmount")*(1+vatRate));

image