Send text in email depends on status of checkbox in WCF7

24 Views Asked by At

I have a checkbox field in WCF7

[checkbox Newsletteranmeldung use_label_element "YES"]

If I send the form an e-mail is send with the Text "Yes", if the form was checked. If the checkbox was empty when sending the form, there ist no text (it's empty). But I want to get a "NO" as output. How to do this?

1

There are 1 best solutions below

0
Aurovrata On

You want to use a toggle button which changes its value each time you click on it.

Place a

<button id="toggle-confirm"> Confirm ? </button>

element in your form along with a hidden field to store the toggled value,

[hidden confirm "no"] //default no

a jquery script to toggle the value each time the button is clicked:

$('button#toggle-confirm').on('change',(e)=>{
 let $hid = $('input[name="confirm"]'),
     $button = $(e.target);
 switch($hid.value()){
   case 'no':
     $hid.value('yes');
     $button.text('Confirmed');
     break;
   case 'yes':
     $hid.value('no');
     $button.text('Confirm?');
     break;
  }
});

Use the hidden confirm mail tag in your email notification