Calculation with child table

Hello,

I used a custom script and it works perfectly but it does not work when i convert it to a child table for use in another document. Please help

cur_frm.cscript.calc1 = function(doc, cdt, cdn) {

if (doc.calc1 && doc.calc2) {
doc.calc3 = doc.calc2/doc.calc1*100;
refresh_field(‘calc3’);
}
}

cur_frm.cscript.calc2 = cur_frm.cscript.calc1;

@PICK_MIX do you is using a old standard for custom script, the new standard is:

frappe.ui.form.on("DocType", "fieldname", function(frm, cdt, cdn){
    var doc = frm.doc;
});

thanks , do u mean changing it to this? My doctype name is nestle and field name is calc1 so using your suggestion, would it look like down below. thanks so much for your help

frappe.ui.form.on(“Nestle”, “calc”, function(frm, cdt, cdn){
var doc = frm.doc;
});