Two way data binding for form inputs

i have one input in form1, form2 will be created based on form 1 when form 1 has a value on its field and will be deleted again when its empty.

my question is that i want to do two ways data binding in the twos form, i already tried to implement it with bind() helper method but i think it dosn’t work for my case.
is there any possibilities how can i do that?

i com up with two solutions which are working just fine.

first method is by listening to OnChange event on both forms and change the value

$$(“form1”).attachEvent(“onCahnge”, function(){
var val= this.getValues();
$$(“form2”).setValues(val);
});,

$$(“form2”).attachEvent(“onChange”, function(){
var val= this.getValues();
$$(“form1”).setValues(val);
});,

second method using bind helper method

$$(“form2”).bind($$(“form1”));
$$(“form1”).bind($$(“form2”));

1 Like