Add if no same mail is available in the textarea field

ID’s should be single use, not for everything. For everything just use the class.

While running it, open up the console and watch the value of the array. I can assist more when I get home, but work I do not have the tools to work on that type of development.

I removed ID
input type=“checkbox” class=“emailsec” value="<?php echo $row['firma_emaili']; ?>"
$(document).on(‘change’, ‘.emailsec’, function(){

Now, automatically check the boxes of the emails in the “emails” array

Took a bit to understand what you needed, but I eventually got there!

I solved the important problem with your help

how to loop?

array variable: emails = [“[email protected]”, "[email protected]", "[email protected]"];

$(‘input[value=“[email protected]”]’).attr(‘checked’, true);

I did a loop like this and it works
However, correct coding?

for(let i = 0; i < emails.length; i++){
            $('input[value="' + emails[i] + '"]').attr('checked', true);
          }

Looks fine to me and if it works, you are fine.

Yes it works, thank you very much for your help again

Sponsor our Newsletter | Privacy Policy | Terms of Service