1

How do i create an array from an unknown number of checkboxes, adding the values to the array using jquery? and then posting the array?

2 Answers 2

1
var arr = $.map($('input[type="checkbox"]:checked'),function(checkbox){
                    return checkbox.value;
                })
Sign up to request clarification or add additional context in comments.

Comments

1

You can try this:

function updateTextArea() {         
     var allVals = [];
     $('#c_b :checked').each(function() {
       allVals.push($(this).val());
     });
     $('#t').val(allVals)
  }
 $(function() {
   $('#c_b input').click(updateTextArea);
   updateTextArea();
 });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.