Log which button submitted form

I have 2 forms on my home page, one at top, and one at the bottom. Same type of form with 2 fields, Name and Email. I have a data connection and everything works great.
But I’d like to know which form the data came from without having to create different fields or DB for the forms.

I think the code would be this, just have to figure out how to get at the submitting button’s name.
Any help would be appreciated.

Terrell

$w(‘#dataset1’).onBeforeSave(() => {
$w(‘#dataset1’).setFieldValue(‘button-name-field-in-DB’, NAME-OF-BUTTON)
});

$w(“#myButton”).label (if button is called myButton in Properties Panel).

The situation is I have 2 buttons #button1 and #button2, I wanted get which one of these submitted the data. on my page I have 2 of the forms pictured. So I want the label of the one that the user pressed.

above the $w.OnReady, declare a global var strButtonClicked= “”. On the onClcik for each button, do this:

export function button1_Click ($w, event) { // or whatever its name is
strButtonClicked=“button1”
}

and export function button2_Click ($w, event) { // or whatever its name is
strButtonClicked=“button2”
}
Then, on the onBeforeSave, set the value of the var strButtonClicked to the correct collection field with setFieldValue as you did and you´re done.