button.disable() doesn't work

Hello, I have a page with a SUBMIT button at the bottom, which gathers user input and upon clicking the button it saves the data into a collection.

The code at the bottom of the rest of my code is:

export function button6_click(event, $w) {
    $w('#button6').disable()

    $w("#dataset1").onReady(() => {
 var tools = '';
 var strategies = '';
 for (var t = 0; t <= 14; t++) {
 if (selections[t] !== undefined) {
                tools += selections[t];
            }
        }
 for (var s = 15; s <= 44; s++) {
 if (selections[s] !== undefined) {
                strategies += selections[s];
            }
        }
        $w("#dataset1").setFieldValue('digitaltools_pdf', tools);
        $w("#dataset1").setFieldValue('strategies_pdf', strategies);
    });

}

When I click on the SUBMIT, I get the following errors:

1 - The unknown file failed to upload. Please try again later. undefinedsave operation failed: 
2 - DatasetError: Operation cancelled by user code. [object Object] 

My questions are:

  • what do those errors mean and how can I solve them?
  • the line $w(‘#button6’).disable() should grey-out the button, but it doesn’t. What is wrong here?

The page is on this site, on the page called “SUBMIT” :

Any help would be appreciated. Thank you! :slight_smile:

Update to code I’ve tried now:

export function button6_click(event, $w) {
    $w('#button6').disable().then(() => {

        $w("#dataset1").onReady(() => {
 var tools = '';
 var strategies = '';
 for (var t = 0; t <= 14; t++) {
 if (selections[t] !== undefined) {
                    tools += selections[t];
                }
            }
 for (var s = 15; s <= 44; s++) {
 if (selections[s] !== undefined) {
                    strategies += selections[s];
                }
            }
            $w("#dataset1").setFieldValue('digitaltools_pdf', tools);
            $w("#dataset1").setFieldValue('strategies_pdf', strategies);
        });
    });
}

Same errors result…