2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

I want to retrieve the values of checkboxes using jQuery

How to use jQuery to get the values of the checked checkboxes, and i also ant to put it into a textarea immediately?
userimage


The following code will solve the problem for you


function writeInTextArea() {         

     var checkBoxVals = [];

     $('#c_b :checked').each(function() {

       checkBoxVals.push($(this).val());

     });

     $('#t').val(checkBoxVals);

  }

 $(function() {

   $('#c_b input').click(writeInTextArea);

   writeInTextArea();

 });

Answer is