Answer the question
In order to leave comments, you need to log in
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>
<script>
function setEmail(email){
var all = document.getElementById("to_all");
if(all.value != ""){
all.value += ', '
}
all.value += email;
console.log(all.value);
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question