Live update field values based on another

I have two fields:

I am looking to update values on one when another one changes (without the need to save/submit the form).

For ex.
If I type 1 in square meter, square foot should automatically display 10.7639, If I then type 0 to make it 10, the values in square foot should go 107.639 and so on.

If I then replace values in square foot, and start typing 100, then square meter should show: 0.092903, 0.92903, 9.2903 one after another as I continue typing 1-0-0 in square foot.

I hope I made myself clear.

Is there a way to achieve this ?

That for, you have to apply the client script for that doctype.

frappe.ui.form.on('Your DocType', {
    square_meters: function(frm) {
        let square_meters = frm.doc.square_meters || 0;
        let square_feet = (square_meters * 10.7639)
        frm.set_value('square_feet', square_feet);
    },
    square_feet: function(frm) {
        let square_feet = frm.doc.square_feet || 0;
        let square_meters = (square_feet / 10.7639)
        frm.set_value('square_meters', square_meters);
    }
});

Please set your fieldname, doctype name in the script.

1 Like

I wrote a similar script. This works only after pressing β€˜Tab’ or clicking outside after making modification.

Is there a way where the field get automatically updated as we type in new values.

For reference, take this website: Unit Converter and type in some values.