Disable Submit Button if site member submitted to Form already.

Hi Guys

I need some help. I have a submission form connected to a database collection. I want site members to be able to make only one submission per member account.

If the logged-in site member has made a submission to the collection previously, I want the submission form fields to be disabled inclusive of the submit button.

I understand that I would have to employ .if statements and a Data Query.

I am still learning wix code but I am stuck as to how to put this all together (Code wise).

Could someone help, please?

Make the Submit button disabled on load.
Query the submission collection database owner filed for the current member Id.
If the returned totalCount === 0 enable the button.
See:
Query with eq:

https://www.wix.com/velo/reference/wix-data/wixdataquery/eq

totalCount results:
https://www.wix.com/velo/reference/wix-data/wixdataqueryresult/totalcount

button enabling:
https://www.wix.com/velo/reference/$w/disabledmixin/enable

Hi J.D

This is what I got, But some how every-time I go back to the page the button is re-enable. cant seem to find what I a doing wrong.

import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;

$w.onReady(function () {
wixData.query(“LiveRadio”)
.find()
.then( (results) => {
if(results.items.length > 0) {
for (var i = 0; i < results.items.length; i++) {
if (results.items[i].Owner === wixUsers.currentUser.id) {
$w(“#button40”).disable()
break
} else {
$w(“#button40”).enable()
}
}

} 

} )
.catch( (err) => {
let errorMsg = err;
} );
});

export function button40_click(event) {
$w(“#button40”).disable()
}