Probably something simple but any assistance would be appreciated.
The code from export function button15_click(event,$w) onwards is giving me some problems and after many days trying to resolve I am at a loss.
The page is an RSVP form for a wedding. An RSVP can have up to 7 individual guests.
When an RSVP is entered the data is returned to the collection, and depending on whether they select Attending or Not Attending they are redirected to either a Thank You page which then triggers a confirmation email to the guest and an RSVP submitted email to the Bride/Groom, or a Sorry page, which provides only a close button which returns them to home page. It only requires 1 guest on the RSVP to select attending to trigger, or all guests on an RSVP to select Not Attending to trigger the respective actions.
The problem I have is if someone has already entered an RSVP with the same email address. When they click the Submit button (button15) the form should clear (this is working) and display a message with instructions on how to change RSVP (this is also working), but it should not send any emails, either confirmation to guest or RSVP submitted to bride/groom, not return the data that was entered to the collection.
It is not returning the data to the collection which is great, but for some reason it is sending both emails.
The invites are going out this weekend so I desperately need to solve this.
I have included the entire page code below for reference.
import wixlocation from ‘wix-location’;
import wixData from ‘wix-data’;
export function dropdown1_change(event){
if ($w(‘#dropdown1’).value=== “1”){
($w(‘#text80’)).expand();
($w(‘#group107’)).expand();
($w(‘#group108’)).collapse();
($w(‘#group109’)).collapse();
($w(‘#group110’)).collapse();
($w(‘#group111’)).collapse();
($w(‘#group112’)).collapse();
} else if ($w(‘#dropdown1’).value === “2”){
($w(‘#text80’)).expand();
($w(‘#group107’)).expand();
($w(‘#group108’)).expand();
($w(‘#group109’)).collapse();
($w(‘#group110’)).collapse();
($w(‘#group111’)).collapse();
($w(‘#group112’)).collapse();
} else if ($w(‘#dropdown1’).value === “3”){
($w(‘#text80’)).expand();
($w(‘#group107’)).expand();
($w(‘#group108’)).expand();
($w(‘#group109’)).expand();
($w(‘#group110’)).collapse();
($w(‘#group111’)).collapse();
($w(‘#group112’)).collapse();
} else if ($w(‘#dropdown1’).value === “4”){
($w(‘#text80’)).expand();
($w(‘#group107’)).expand();
($w(‘#group108’)).expand();
($w(‘#group109’)).expand();
($w(‘#group110’)).expand();
($w(‘#group111’)).collapse();
($w(‘#group112’)).collapse();
} else if ($w(‘#dropdown1’).value === “5”){
($w(‘#text80’)).expand();
($w(‘#group107’)).expand();
($w(‘#group108’)).expand();
($w(‘#group109’)).expand();
($w(‘#group110’)).expand();
($w(‘#group111’)).expand();
($w(‘#group112’)).collapse();
} else if ($w(‘#dropdown1’).value === “6”){
($w(‘#text80’)).expand();
($w(‘#group107’)).expand();
($w(‘#group108’)).expand();
($w(‘#group109’)).expand();
($w(‘#group110’)).expand();
($w(‘#group111’)).expand();
($w(‘#group112’)).expand();
} else if ($w(‘#dropdown1’).value===“0”){
($w(‘#text80’)).collapse();
($w(‘#group107’)).collapse();
($w(‘#group108’)).collapse();
($w(‘#group109’)).collapse();
($w(‘#group110’)).collapse();
($w(‘#group111’)).collapse();
($w(‘#group112’)).collapse();
}
}
import {sendEmail} from ‘backend/email’;
$w.onReady( function () {
});
export function button15_click(event,$w) {
wixData.query("YvonneandJosh")
.eq("email", $w('#input3').value)
.find()
.then(res => { **if** (res.length > 0)
{
$w('#input1').value=""
$w('#input2').value=""
$w('#input3').value=""
$w('#input4').value=""
$w('#input5').value=""
$w('#input6').value=""
$w('#input7').value=""
$w('#input8').value=""
$w('#input9').value=""
$w('#input10').value=""
$w('#input11').value=""
$w('#input12').value=""
$w('#input13').value=""
$w('#input14').value=""
$w('#radioGroup1').value=""
$w('#radioGroup8').value=""
$w('#radioGroup9').value=""
$w('#radioGroup10').value=""
$w('#radioGroup11').value=""
$w('#radioGroup12').value=""
$w('#radioGroup13').value=""
$w('#textBox1').value=""
$w('#textBox3').value=""
$w('#textBox4').value=""
$w('#textBox5').value=""
$w('#textBox6').value=""
$w('#textBox8').value=""
$w('#textBox9').value=""
$w('#textBox10').value=""
$w('#textBox11').value=""
$w('#textBox12').value=""
$w('#textBox13').value=""
$w('#textBox14').value=""
$w('#textBox15').value=""
$w('#group106').expand()
} **else if** ($w('#input15').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
$w('#dataset2').save();
console.log("Dataset2 is saving")
$w('#dataset3').save();
console.log("Dataset3 is saving")
$w('#dataset4').save();
console.log("Dataset4 is saving")
$w('#dataset5').save();
console.log("Dataset5 is saving")
$w('#dataset6').save();
console.log("Dataset6 is saving")
$w('#dataset7').save()
console.log("Dataset7 is saving")
confirmRSVP();
} **else if** ($w('#input13').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
$w('#dataset2').save();
console.log("Dataset2 is saving")
$w('#dataset3').save();
console.log("Dataset3 is saving")
$w('#dataset4').save();
console.log("Dataset4 is saving")
$w('#dataset5').save();
console.log("Dataset5 is saving")
$w('#dataset6').save();
console.log("Dataset6 is saving")
confirmRSVP();
} **else if** ($w('#input11').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
$w('#dataset2').save();
console.log("Dataset2 is saving")
$w('#dataset3').save();
console.log("Dataset3 is saving")
$w('#dataset4').save();
console.log("Dataset4 is saving")
$w('#dataset5').save();
console.log("Dataset5 is saving")
confirmRSVP();
} **else if** ($w('#input9').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
$w('#dataset2').save();
console.log("Dataset2 is saving")
$w('#dataset3').save();
console.log("Dataset3 is saving")
$w('#dataset4').save();
console.log("Dataset4 is saving")
confirmRSVP();
} **else if** ($w('#input6').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
$w('#dataset2').save();
console.log("Dataset2 is saving")
$w('#dataset3').save();
console.log("Dataset3 is saving")
confirmRSVP();
} **else if** ($w('#input4').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
$w('#dataset2').save();
console.log("Dataset2 is saving")
confirmRSVP();
} **else if** ($w('#input1').value !== "") {
$w('#dataset1').save();
console.log("Dataset1 is saving")
confirmRSVP();
}
});
let myprovider = “gmail”; //use her the alias you used for this service in emailJS
let mytemplate = “yjrsvpconfirmation”; //use her the template name you defined in emailJS
let myparams = {
“Email”: $w(‘#input3’).value,
“Name1”: $w(‘#input1’).value,
“Surname1”: $w(‘#input2’).value,
“Food1”: $w(‘#textBox1’).value,
“Songs1”: $w(‘#textBox3’).value,
“Name2”: $w(‘#input4’).value,
“Surname2”: $w(‘#input5’).value,
“Food2”: $w(‘#textBox4’).value,
“Songs2”: $w(‘#textBox10’).value,
“Name3”: $w(‘#input6’).value,
“Surname3”: $w(‘#input7’).value,
“Food3”: $w(‘#textBox5’).value,
“Songs3”: $w(‘#textBox11’).value,
“Name4”: $w(‘#input9’).value,
“Surname4”: $w(‘#input8’).value,
“Food4”: $w(‘#textBox5’).value,
“Songs4”: $w(‘#textBox12’).value,
“Name5”: $w(‘#input11’).value,
“Surname5”: $w(‘#input10’).value,
“Food5”: $w(‘#textBox7’).value,
“Songs5”: $w(‘#textBox13’).value,
“Name6”: $w(‘#input13’).value,
“Surname6”: $w(‘#input12’).value,
“Food6”: $w(‘#textBox8’).value,
“Songs6”: $w(‘#textBox14’).value,
“Name7”: $w(‘#input15’).value,
“Surname7”: $w(‘#input14’).value,
“Food7”: $w(‘#textBox9’).value,
“Songs7”: $w(‘#textBox15’).value,
“Attending1”: $w(‘#radioGroup1’).value,
“Attending2”: $w(‘#radioGroup8’).value,
“Attending3”: $w(‘#radioGroup9’).value,
“Attending4”: $w(‘#radioGroup10’).value,
“Attending5”: $w(‘#radioGroup11’).value,
“Attending6”: $w(‘#radioGroup12’).value,
“Attending7”: $w(‘#radioGroup13’).value,
};
sendEmail (myprovider, mytemplate, myparams);
let mytemplate1 = “yjrsvpsubmitted”; //use her the template name you defined in emailJS
let myparams1 = {
“Name1”: $w(‘#input1’).value,
“Surname1”: $w(‘#input2’).value,
“Food1”: $w(‘#textBox1’).value,
“Songs1”: $w(‘#textBox3’).value,
“Name2”: $w(‘#input4’).value,
“Surname2”: $w(‘#input5’).value,
“Food2”: $w(‘#textBox4’).value,
“Songs2”: $w(‘#textBox10’).value,
“Name3”: $w(‘#input6’).value,
“Surname3”: $w(‘#input7’).value,
“Food3”: $w(‘#textBox5’).value,
“Songs3”: $w(‘#textBox11’).value,
“Name4”: $w(‘#input9’).value,
“Surname4”: $w(‘#input8’).value,
“Food4”: $w(‘#textBox5’).value,
“Songs4”: $w(‘#textBox12’).value,
“Name5”: $w(‘#input11’).value,
“Surname5”: $w(‘#input10’).value,
“Food5”: $w(‘#textBox7’).value,
“Songs5”: $w(‘#textBox13’).value,
“Name6”: $w(‘#input13’).value,
“Surname6”: $w(‘#input12’).value,
“Food6”: $w(‘#textBox8’).value,
“Songs6”: $w(‘#textBox14’).value,
“Name7”: $w(‘#input15’).value,
“Surname7”: $w(‘#input14’).value,
“Food7”: $w(‘#textBox9’).value,
“Songs7”: $w(‘#textBox15’).value,
“Attending1”: $w(‘#radioGroup1’).value,
“Attending2”: $w(‘#radioGroup8’).value,
“Attending3”: $w(‘#radioGroup9’).value,
“Attending4”: $w(‘#radioGroup10’).value,
“Attending5”: $w(‘#radioGroup11’).value,
“Attending6”: $w(‘#radioGroup12’).value,
“Attending7”: $w(‘#radioGroup13’).value,
“Food”: $w(‘#textBox1’).value,
“Songs”: $w(‘#textBox3’).value,
};
sendEmail (myprovider, mytemplate1, myparams1);
}
function confirmRSVP(){
if (($w(‘#radioGroup1’).value === “Attending”) ^ ($w(‘#radioGroup8’).value.value === “Attending”) ^ ($w(‘#radioGroup9’).value.value === “Attending”) ^ ($w(‘#radioGroup10’).value.value === “Attending”) ^ ($w(‘#radioGroup11’).value.value === “Attending”) ^ ($w(‘#radioGroup12’).value.value === “Attending”) ^ ($w(‘#radioGroup13’).value.value === “Attending”))
{
wixlocation.to(“/yvonneandjosh-thankyou”);
} else {
wixlocation.to(“/yvonneandjosh-sorry”);
}
}
export function text150_click(event) {
$w(‘#input1’).value=“”
$w(‘#input2’).value=“”
$w(‘#input3’).value=“”
$w(‘#input4’).value=“”
$w(‘#input5’).value=“”
$w(‘#input6’).value=“”
$w(‘#input7’).value=“”
$w(‘#input8’).value=“”
$w(‘#input9’).value=“”
$w(‘#input10’).value=“”
$w(‘#input11’).value=“”
$w(‘#input12’).value=“”
$w(‘#input13’).value=“”
$w(‘#input14’).value=“”
$w(‘#radioGroup1’).value=“”
$w(‘#radioGroup8’).value=“”
$w(‘#radioGroup9’).value=“”
$w(‘#radioGroup10’).value=“”
$w(‘#radioGroup11’).value=“”
$w(‘#radioGroup12’).value=“”
$w(‘#radioGroup13’).value=“”
$w(‘#textBox1’).value=“”
$w(‘#textBox3’).value=“”
$w(‘#textBox4’).value=“”
$w(‘#textBox5’).value=“”
$w(‘#textBox6’).value=“”
$w(‘#textBox8’).value=“”
$w(‘#textBox9’).value=“”
$w(‘#textBox10’).value=“”
$w(‘#textBox11’).value=“”
$w(‘#textBox12’).value=“”
$w(‘#textBox13’).value=“”
$w(‘#textBox14’).value=“”
$w(‘#textBox15’).value=“”
$w(‘#group106’).collapse();
}