Background: I am sending email notifications on form submittal. The wix documentation ( https://support.wix.com/en/article/how-to-send-an-email-on-form-submission ) is very helpful, but sends the email only in text format. Tal has a write-up that shows how to easily send the emails in html format: https://www.wix.com/code/home/forum/questions-answers/how-to-design-my-email-notification . This is great, because now the email notifications can look attractive and professional.
However, I have another challenge now. I haven’t figured out how to include my wix input variables (e.g. ${$w(“#input1”).value} ) within an href. For example, I want to set up a link to direct respondents to a website based on certain input variables.
This, for example, does not work (the offending code is bolded):
import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;
$w.onReady(function () {
$w(“#dataset1”).onAfterSave(sendFormData);
});
function sendFormData() {
const subject = Welcome
;
const body = Please visit your page on our website. <a href="https://www.xxxxxx.com/to/m5pMOI?firstname=${$w("#input1").value}&lastname=${$w("#input2").value}">click here</a>
;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
Does anyone know the solution?
Thanks!