RESOLVED - On/Off Bottom for erase rows table

Hi, I’m trying to make a button on off that when it’s on gives me the possibility to delete the rows of a table
I’m learning javascript if someone can explain how to correct this code thanks

function onoff() {
if $w(“#BottDeleteRecord”).value() === enable {
$w(“#BottDeleteRecord”).disable();
}else{
$w(“#BottDeleteRecord”).enable();
}

export function BottDeleteRecord_dblClick() {
onoff();
if $w(“#BottDeleteRecord”).enable=== true() {
export function TabEventi_rowSelect(event, $w) {
const index = event.rowIndex;

			//get the _id attribute of the relevant record 
		const idToDelete = event.target.rows[index]._id; 

  			//remove the record from the collection          
		wixData.remove("RedirectCerimonie", idToDelete) 
  			.then(() => { 

     		//refresh the table with the updated info 
     		$w('#TabEventi').refresh(); 
  			}) 
			.catch((err) => { 
   			let errorMsg = err; 
       		console.log(errorMsg); 
  			}); 
		} 
	} 

}

Thanks

Hi,
This is your function:
Please note the comments

function onoff() {
	if $w("#BottDeleteRecord").value() === enable { // There is no value property to button element. I guess what you meant to check if the button is currently enabled.  
			$w("#BottDeleteRecord").disable(); // If so, disable the button
	}else{ // If other then enable
		$w("#BottDeleteRecord").enable(); // disable it 
	}
}

Here is some fixes for the on off function:

export function onoff(event, $w) {
	if ($w("#BottDeleteRecord").enabled === true) { // .enabled: Indicates if the element is enabled or disabled.
		$w("#BottDeleteRecord").disable();
	} else {
		$w("#BottDeleteRecord").enable();
	}
}

Good luck!
Roi

Thank you very much, very clear. I still have a long way to go to learn javascript, and it is only by solving these errors that I find the solution.

Thank you so much

Glad to help !
Roi