# How do I delete an entry

**URL:** <https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [February 6, 2018, 7:58pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475 "2018-02-06T19:58:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 6, 2018, 7:58pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/1 "2018-02-06T19:58:53Z")

</div>

Ok Ive got a form that the user can fill in and I can display the contents of that collection  
but I need to be able to remove a single entry at a time as some users are filling out my form incorrectly- how do I create a delete Admin feature-very simple as I new

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 6, 2018, 8:02pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/2 "2018-02-06T20:02:38Z")

</div>

sorry that doesnt read right  
I want to build a facility that will enable me to remove a record from the database

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [February 6, 2018, 8:42pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/3 "2018-02-06T20:42:41Z")

</div>

Hi,  
You can simply right click on the record line and delete it. Do you wish to create a page for this scenario instead of deleting is from the editor?

Tal.

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 6, 2018, 10:02pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/4 "2018-02-06T22:02:14Z")

</div>

Yes Tal i want a page for this purpose as i dont want my users gaining access to the editor-cheers

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [February 7, 2018, 12:05pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/5 "2018-02-07T12:05:19Z")

</div>

Hi,

You can create a password protected admin page and share the password only with the people who should have access to it.

Use dataset actions to control the collection  
See more [here](https://support.wix.com/en/article/dataset-actions-for-buttons)

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 7, 2018, 2:34pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/6 "2018-02-07T14:34:05Z")

</div>

![](https://us1.discourse-cdn.com/wix/original/3X/0/8/08876573baa31307a3cab9b6f4755f1437f88df5.png)  
This is my table and users are not always filling them in correctly I wish to be able to delete one row of my choice -Is this possible if so how do I achieve this- Ive tried adding a button and conntecting it to the dataset but the button function delete is not available - can anyone send me a picture of how it would look  
Thanks jer

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [February 7, 2018, 6:15pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/7 "2018-02-07T18:15:25Z")

</div>

Hi,  
Lets say that you’ve connected a table to your DB collection. Make sure to set the dataset mode is " **Read & Write**". Than, you should add a [table row event](https://www.wix.com/code/reference/$w.TableRowEvent.html) and once someone clicks on the table row, it will be deleted from the collection by adding the following code:

```javascript
import wixData from 'wix-data';

export function table1_rowSelect(event, $w) {
	//get the index of the row which was clicked by the user	
	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("collectionName", idToDelete)
		.then(() => {
		//refresh the table with the updated info
			$w('#table1').refresh();
		})
		.catch((err) => {
			let errorMsg = err;
		});
}

```

I recommend, as Ido suggested, to set a password to the page so that only the relevant people will have permission to delete records from your collection.

I hope it’s clear.

Best,  
Tal.

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 8, 2018, 7:52am UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/8 "2018-02-08T07:52:02Z")

</div>

how do I add a [table row event](https://www.wix.com/code/reference/$w.TableRowEvent.html) ive looked through Wix support but cant find it  
Ive password protected the page so all good there-i just now need to have the option to delete a row  
Thankyou for your help Tal

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [February 8, 2018, 8:35am UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/9 "2018-02-08T08:35:21Z")

</div>

Hi,

Add an onRowSelect() function:

![](https://us1.discourse-cdn.com/wix/original/3X/a/8/a8d3a3e9bbea39685041f471ddf606e624ab0c30.png)  
This will create the following code in the code pane:

```javascript
export function table1_rowSelect(event, $w) {
	//Add your code for this event here: 
}

```

See the API doc for [https://www.wix.com/code/reference/$w.Table.html#onRowSelect](https://www.wix.com/code/reference/$w.Table.html#onRowSelect) for more information.

Yisrael

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 8, 2018, 12:09pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/10 "2018-02-08T12:09:08Z")

</div>

![](https://us1.discourse-cdn.com/wix/original/3X/5/3/53527e119d1f12111e2d27a271497df46e7413fa.png)  
OK got that bit but when I paste the code that Tal gave me I get a ton of errors - do I have to add a button I dont get where the action of the code should go-Im from an XCode background and this confusing to me  
thanks for helping everyone  
Jer

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [February 8, 2018, 12:30pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/11 "2018-02-08T12:30:09Z")

</div>

The code that Tal provided needs to go in the table1\_rowSelect() function. You need to change **collectionName** to the name of your database collection.

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 8, 2018, 1:59pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/12 "2018-02-08T13:59:56Z")

</div>

![](https://us1.discourse-cdn.com/wix/original/3X/6/4/64f5c05af02ed6984f91f1cc128225016e034a04.png)  
HHmmm

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [February 8, 2018, 2:04pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/13 "2018-02-08T14:04:50Z")

</div>

The **import wixData from ‘wix-data’;** statement should go at the top of the file.

Delete the first **export function table1\_rowSelect(event, $w)**

I would suggest familiarizing yourself with basic coding concepts to enable you to accomplish what you want. There are a wealth of Javascript coding sites which will help you learn Javascript from basic to advanced - [Javascript.info](http://javascript.info/) is a good one.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [February 8, 2018, 2:10pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/14 "2018-02-08T14:10:58Z")

</div>

Here’s the corrected code:

```javascript
import wixData from 'wix-data';

$w.onReady (function () {

});

export function table1_rowSelect(event, $w) {
   //get the index of the row which was clicked by the user    
   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("FutureData", idToDelete)
      .then(() => {
          //refresh the table with the updated info
          $w('#table1').refresh();
      })
      .catch((err) => {
           let errorMsg = err;
      });
}

```

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 8, 2018, 4:39pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/15 "2018-02-08T16:39:44Z")

</div>

Yea sorry that didnt work either so I will try to get my head around it later  
Regards Jer

 ![](https://us1.discourse-cdn.com/wix/original/3X/d/d/ddef56b65dad0fae17e95ace1d3988d000a5d89f.png)

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 9, 2018, 4:29pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/16 "2018-02-09T16:29:22Z")

</div>

OOHHH cant seem to find out how this works please can someone help ive tested on Mac and PC

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [February 11, 2018, 12:39pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/17 "2018-02-11T12:39:49Z")

</div>

Hi,

Add **console.log(‘user selected a row’)** below the function declaration line to make sure the event is executed. If you do not see this message when you click a table row re-add the onRowSelect event and try again.

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 11, 2018, 3:18pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/18 "2018-02-11T15:18:31Z")

</div>

No the event is not executing Ido is it possible to do this- is the code in previous messages the correct code or should I start again- I was hoping to put a checkbox in the table so that if the Administratot selects it the row will disappear or a button to execute the delete of the row in the table- has anyone got this working

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [February 12, 2018, 10:27am UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/19 "2018-02-12T10:27:46Z")

</div>

Hi,

Yes, the code should work. Make sure to add the onRowSelect event from the table properties panel.

As an alternative, you can show a lightbox as a confirmation window (to prevent accidental deletions)  
See the thread [**here**](https://www.wix.com/code/home/forum/questions-answers/delete-dynamic-repeater) to get a basic idea on how to achieve that.

---

<div class="post-metadata">

**Author:** ![artformwebservice](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/artformwebservice/32/816_2.png) [@artformwebservice](https://forum.wixstudio.com/u/artformwebservice)\
**Post date:** [February 12, 2018, 12:18pm UTC](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475/20 "2018-02-12T12:18:56Z")

</div>

Im getting in a right mess here ive read so much and still cant get this working can anyone look at my table to see whats going on for meRegards Jer

[Next page](https://forum.wixstudio.com/t/how-do-i-delete-an-entry/32475.md?page=2)
