# Send email after onclick button

**URL:** <https://forum.wixstudio.com/t/send-email-after-onclick-button/7101>\
**Category:** Ask the community\
**Tags:** wix-forms, question, code\
**Created:** [October 2, 2021, 1:27pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101 "2021-10-02T13:27:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![saadinioh5](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@saadinioh5](https://forum.wixstudio.com/u/saadinioh5)\
**Post date:** [October 2, 2021, 1:27pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/1 "2021-10-02T13:27:18Z")

</div>

Hello I’m creating a hiring website and for employers to see someone’s cv , they need to ask for permission.  
When an employer asks sor someon’s cv they see this in their page

![](https://us1.discourse-cdn.com/wix/original/3X/f/8/f8f14f6117b493dfe996e070ddf079e6640afa12.png)

Then from my admin page I can give them the permission to see it

 ![](https://us1.discourse-cdn.com/wix/original/3X/c/9/c9c334a59f1d0721f6f8d94176dc4e5540ae223a.png)  
and it appears in their member page like this :

![](https://us1.discourse-cdn.com/wix/original/3X/5/1/517f484f6b728ec9610eeaf8f8d5eeeebed3265f.png)

WHAT I WANT :  
I want 2 things :  
-when someone asks to see a cv, the admin recieves an email.  
-when the admin accepts a request, the user gets and email to tell them “your request was accepted”  
I tried to do it with sendgrid the same way people do for forms, but I don’t know how to get data from the dataset/repeater, and I don’t know where to put the sendemail function in my code.  
my code :

```javascript
$w.onReady(function () {
   $w("#dataset1").onReady( () => { 
   $w("#repeater1").forEachItem( ($item, itemData, index) => { $item("#button1").onClick((event) => { 
   $w("#dataset1").refresh() 
   $w("#dataset2").refresh() 
   console.log("you clicked " + itemData._id) $w("#dataset1").getItems(index, 1) 
   .then( (result) => { 
   let items = result.items; 
   let totalCount = result.totalCount; 
   let offset = result.offset; 
   console.log(items) }) 
   .catch( (err) => { 
   let errMsg = err.message; 
   let errCode = err.code; 
   }); 
   }); 
   }); 
   }); 
   });
 

```

---

<div class="post-metadata">

**Author:** ![saadinioh5](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@saadinioh5](https://forum.wixstudio.com/u/saadinioh5)\
**Post date:** [October 2, 2021, 1:40pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/2 "2021-10-02T13:40:04Z")

</div>

PS: I can pay for some help

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [October 2, 2021, 2:05pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/3 "2021-10-02T14:05:27Z")

</div>

Already have tried this …???

> **[Example: Send email with the SendGrid REST interface.](https://forum.wixstudio.com/velo/forum/tips-tutorials-examples/example-send-email-with-the-sendgrid-rest-interface)**
>
> \#Example #Sendgrid #Email #WebModules #ServerSide #backend #3rdPartyServices #fetch Demonstrates SendGrid email API web services Web modules - server-side (backend) code Accessing 3rd Party Services (using backend function) Calling...

> …but I don’t know how to get data from the dataset/repeater…  
> Your REPEATER is connected to which database?  
> Your REPEATER is placed on a dynamic page?  
> How exactly is your setup?

---

<div class="post-metadata">

**Author:** ![saadinioh5](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@saadinioh5](https://forum.wixstudio.com/u/saadinioh5)\
**Post date:** [October 2, 2021, 2:15pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/4 "2021-10-02T14:15:16Z")

</div>

My repeater is connected to the database where there are 3 informations:  
employers(people who request to see cv)  
candidate(the candidate which they want to see the cv)  
dispo(boolean value: if they can see the cv or not)  
in the admin page my repeater shows the pending requests for a cv and when I change the switch value to true the employers can access the cv from their members page.

I tried to do the same thing as the link you sent me but i don’t know how to get values from my data instead of the inputs.  
for example:

```javascript
 const recipient = $w("#input11").value;

```

how do i change the $w(“#input11”).value to “email of the employer to whom i just accepted the request”

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [October 2, 2021, 3:00pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/5 "2021-10-02T15:00:06Z")

</div>

How to get VALUES ???

Try this one…

```javascript
$w.onReady(function () {
    $w("#repeater1").onItemReady(($item, itemData, index)=> { 
        $item("#button1").onClick((event) => {
            console.log(console.log(itemData));
        });
    });
});

```

And here an example…

[https://russian-dima.wixsite.com/login-system/blank-2](https://russian-dima.wixsite.com/login-system/blank-2)

Take a look into CONSOLE and inspect the results when clicking onto the button.

Repeater is of course connected to a DATABASE trough a DATASET.

If you need more help on this → you will find my contact in my profile.

---

<div class="post-metadata">

**Author:** ![saadinioh5](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@saadinioh5](https://forum.wixstudio.com/u/saadinioh5)\
**Post date:** [October 2, 2021, 3:13pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/6 "2021-10-02T15:13:40Z")

</div>

@russian-dima I can’t access the console

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [October 2, 2021, 3:16pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/7 "2021-10-02T15:16:37Z")

</div>

@saadinioh5 Open the shown example in your BROWSER?  
For example if you use GOOGLE-CHROME → Press-F12 and search for CONSOLE.

---

<div class="post-metadata">

**Author:** ![saadinioh5](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@saadinioh5](https://forum.wixstudio.com/u/saadinioh5)\
**Post date:** [October 2, 2021, 4:13pm UTC](https://forum.wixstudio.com/t/send-email-after-onclick-button/7101/8 "2021-10-02T16:13:05Z")

</div>

They don’t let me paste my code but here it is for now

 ![](https://us1.discourse-cdn.com/wix/original/3X/2/9/29cb4aa4fd6791cb4f3276e73c3ce592628c6fd4.png)  
I still can’t recieve an email
