Email/Database & Dropdown Issue

Here’s my website for reference.
https://www.deafhoosiers.com/search-directory

1. I have mailto: set up in the URL in the database. The email icon is connected to the database and is onClick. I tried to test the icon and nothing is happening. I was expecting a pop up of an email app of any kind to show up. Is there a code I need for that part or am I missing something?

2. The dropdown is showing multiples when I only want one value for each category. I tried several tutorials and am still seeing multiples.

Here’s the code for the page: (please note: there’s a search bar code included and they work)

import {local} from 'wix-storage';
 
import wixData from 'wix-data';
 
 
export function searchButton_click() {
    search();
}
 
export function searchBar_keyPress(event, $w) {
 if (event.code === 13){
         search();
    }
}
 
function search() {
    wixData.query('staffdirectory')
   .contains('lastName', $w("#searchBar").value)
   .or(wixData.query('staffdirectory').contains('lastName', $w("#searchBar").value))
  .or(wixData.query('staffdirectory').contains('firstName', $w("#searchBar").value))
  .or(wixData.query('staffdirectory').contains('department', $w("#searchBar").value))
      .find()
       .then(res => {
        $w('#results').data = res.items;
    });
 
}

$w.onReady(function () {
 
 

    wixData.query("staffdirectory")

      .limit(1000)

      .find()

      .then(results => {

 const uniqueItems = getUniqueItems(results.items);

           $w("#llisting").options = buildOptions(uniqueItems);

      });

 

 function getUniqueItems(items) {

 const itemsOnly = items.map(item => item.title);

 return [...new Set(itemsOnly)];

    }

 

 function buildOptions(uniqueList) {

 return uniqueList.map(curr => {

 return {label:curr, value:curr};

        });

    }

});

 

export function llisting_change(event, $w) {

 let sort = $w("#llisting").value;

    $w("#staffdirectory").setFilter(wixData.filter().eq("department", sort));

}

Hi!

  1. If you’re just using a regular email Icon from Buttons section of the Wix Editor and only need one email to send mails to (f.ex. “Contact us” feature), you can check out how to connect it here: https://support.wix.com/en/article/creating-a-clickable-email-address
    (the section “To link a button to an email address” on the bottom)

If you need to take an email from the database and send an email to the different users each time (f.ex: “Sign me up for newsletter” feature), you’ll need to write some code. I would suggest using wixCrm for that ( https://www.wix.com/corvid/reference/wix-crm.html )

  1. About the second one: in your getUniqueItems() function, after you map the array and assign it to itemsOnly array, use a for loop / Lodash .uniq function / any other library’s function / your own custom solution to filter out duplicate values

Thanks. I’ve looked through them. Triggered emails will not work in my case. I have a staff directory with an icon linking to the database. The field is set at url with mailto:

function email_click() {
    wixData.query('staffdirectory')
    .find('email')
    .then(res=> {
    $w("#email").link = res.items;
});
}

It should be very simple. I do show the mailto: when I hover but when clicking, it doesn’t do anything. (Indiana School For The Deaf - Indiana School For The Deaf) but it’s not doing anything when I click on the button. It should automatically open up our email app to send the email.

@jfriede

I dont think that just work like this: You should use wixloaction.to(…)
https://www.wix.com/corvid/reference/wix-location.html#to

And you code should look somethink like that:

import wixLocation from 'wix-location';

...

function email_click() {
    wixData.query('staffdirectory')
    .find('email')
    .then(res=> {
        const eMail= res.items;

        $w("#email").onClick( eMail => {
             const subject = "EMAIL TITLE TEXT";  
             wixLocation.to(
                `mailto:${eMail}?subject=` +         
                encodeURIComponent(subject)    
             ); 
        })
    });
}

@benibrodi Thank you! I tried it, didn’t work and made some tweaks. Works now! YAY! Thank you!

function email_click() {
    wixData.query('staffdirectory')
    .find('email')
    .then(res=> {
 const email= res.items;

        $w("#email").onClick(eMail => {
 const subject = "WEBMAIL";  
             wixLocation.to(`mailto:${email}?subject=` +         
                encodeURIComponent(subject)    
             ); 
        })
    });
}