M
M
mantovpinets2018-01-30 12:03:28
MODX
mantovpinets, 2018-01-30 12:03:28

How to make a dynamic list of email recipients?

Good day.
The page has a form. It has checkboxes. By clicking on the checkbox, the corresponding mailbox addresses should be added to the list of recipients of the letter. For some reason it doesn't work for me. I do like this:

<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 form-group">
 <input type="text" name="addressTo" id="to_all">
 <label for="speciality">Требования к консультанту.</label> <br>
 <label for="">Специализация</label>
 <div style="position:relative;">
 <input type="checkbox" name="speciality1" onclick="setEmail('[email protected]')" value="Терапевтический">
 <span class="specialist">Терапевтический</span>
</div>
<div style="position:relative;"> 
 <input type="checkbox" name="speciality2" onclick="setEmail('[email protected]')" value="Хирургический">
 <span class="specialist">Хирургический</span>
 </div>

And this is JS
spoiler
<script>
 function setEmail(email){
  var all = document.getElementById("to_all");
  if(all.value != ""){
   all.value += ', '
  }
  all.value += email;
  console.log(all.value);
}
</script>

At the very beginning of the page, I specify the following FormIt call
[
Moreover, if I select one specialist, the form is sent to his mailbox. And if I choose 2, it does not go.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question