Mark a checkbox field if one or two options are chosen in the select field

Asked

Viewed 72 times

-1

inserir a descrição da imagem aquiI have a selection field with four options. If option 1 is chosen, I want you to mark a checkbox field (WHITE)

How do I do

  • Julio, consider putting more details in your question, this way you put it makes it difficult to help

  • AMENDED QUESTION !

1 answer

1


Try a JS like that

$('select[name="opcoes"]').on('change', function(){
  $('.checks').find('input[type="checkbox"]').each(function(){
    $(this).prop('checked', false);
  });
  if($(this).val() !== ''){
    $('input[data-id="'+$(this).val()+'"]').prop('checked', true);  
  }
});

I made a fiddle to demonstrate

  • Very good !!!!!

  • @Júlioricardo Don’t forget to mark the answer as correct, so you help other people in the future who have the same problem in the future

  • ;-)........... !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.