hello everyone I need to send an e-mail according to the data selected by the user, but while doing this let email = ""; According to the information from Alan, I need to send an e-mail, but Error: Cannot read properties of undefined (reading 'valid') I am getting an error like
let email = ""; assigns the data from here to the two fields I marked with orange
but I'm getting an error I request your support on the issue thank you in advance
let email = "";
$w.onReady(function () {
let sel = $w("#dropdown1").selectedIndex;
if (sel == 0) {
email = "kadirkocaslan@kocaslanlar.com.tr";
} else if (sel == 1) {
email = "kadir616195@gmail.com";
} else if (sel == 2) {
email = "kadir616195@gmail.com";
} else if (sel == 3) {
email = "kadir616195@gmail.com";
} else if (sel == 4) {
email = "kadir616195@gmail.com";
} else {
email = "kocaslanlarhol@gmail.com";
}
console.log('email', email)
});
$w.onReady(function () {
$w('#button14').onClick(async () => {
const passedValidations = checkFormFields();
if (passedValidations) {
const emailResult = await sendEmail($w(email).value,$w('#input49').value, $w('#textBox10').value);
if (emailResult[0].statusCode === SUCCESS_CODE) {
displayMessage('E-posta gönderildi.');
} else {
displayMessage('E-posta gönderilirken hata oluştu, lütfen SendGrid hesap ayrıntılarınızı doğrulayın.');
}
} else {
displayMessage('Doğrulama hatası, lütfen giriş alanlarınızı gözden geçirin.');
}
})
function checkFormFields() {
return $w(email).validity.valid && $w('#input49').validity.valid && $w('#textBox10').validity.valid;
}
function displayMessage(message) {
$w('#text48').text = message;
$w('#text48').show();
$w('#text48').hide('fade', { delay: 5000 });
}
});
You should put everything in 1 $w.onReady block instead of having several $w.onReady.
You wrote $w(email) instead of $w('#email')