Change field value before submit

Hi, i have a dynamic page that connects to collection1, it have a control# and a title field, and other fields, it have a submit button that links to a form, this form connects to collection2, and i
want to use the control# and title from collection1, i tried using hidden fields and change values on submit onclick event, but don’t work, i been reading that i need to use setFieldValue

My collection field in collection1 is Control1, my form field is col1_control1
My collection field in collection2 is Control2, my form field is col2_control2

I want to copy the value of col1_control1 and save it in Control2, how i do that?
if i use:
$w(“#collection2”).setFieldValue(“Control2”, $w(col1_control1).value);
$w(“#collection2”).save;
it make another field in collection2 called [Control2] and set the value.

the example in documentation is:
$w(“#myDataset”).setFieldValue(“title”, “New Title”);
$w(“#myDataset”).save();

“title” is the collection field or the form field?

I’m really confused, hope somebody can help me.

Thanks in advance!

Hey there,

In the example, “title” is the field key in the collection.

Wow, finally got it, i rename Title in my collection to Control, but the field key still title, it’s was hard but now its up and running
Thanks!!