Here’s how to handle the commas:
let comma = ""; // no comma needed for first option in list
let intrests = `\rIntérêts: `;
if ($w("#ArticlesCheckbox").checked) {
intrests = intrests + "Articles";
comma = ", ";
}
if ($w("#EtaiementCheckbox").checked) {
intrests = intrests + comma + "Etaiement";
comma = ", ";
}
if ($w("#PasserelleCheckbox").checked) {
intrests = intrests + comma + "Passerelle";
comma = ", ";
}
if ($w("#PontCheckbox").checked) {
intrests = intrests + comma + "Pont";
comma = ", ";
}
if ($w("#OutilCoffrantCheckbox").checked) {
intrests = intrests + comma + "Outil Coffrant";
comma = ", ";
}
if ($w("#ButonCheckbox").checked) {
intrests = intrests + comma + "Buton";
comma = ", ";
}
if ($w("#PortiqueCheckbox").checked) {
intrests = intrests + comma + "Portique";
}
if ($w("#MaritimeCheckbox").checked) {
intrests = intrests + comma + "Maritime";
comma = ", ";
}
if ($w("#DemolitionCheckbox").checked) {
intrests = intrests + comma + "Demolition";
comma = ", ";
}
if ($w("#SupportGrueCheckbox").checked) {
intrests = intrests + comma + "Support Grue";
comma = ", ";
}
if ($w("#DemolitionCheckbox").checked) {
intrests = intrests + comma + "Demolition";
comma = ", ";
}
if ($w("#AutreCheckbox").checked) {
intrests = intrests + comma + "Autre";
}
if(comma !== ", ")
intrests = "";
I use a variable called comma, which as you can see, I start it out as blank. It will only “become” a comma once an option is included in the list. Then every time after that a comma will be put between options.
A nice side-effect from this is if after checking all of the checkboxes none has been checked, we can just clear the intrests string to blank and it won’t appear in the body of the email.
There might be better ways to do this, but my brain is tired. This works and at least gives you a presentable email.
Note: I did not make these changes to your site.