1

I have this code:

var addNew = $('#divListBox').find(':checked')
 .map(function() {
 return $(this).val();
 }).get();

I want to know if there's a way to get all the value that's checked and put them in a collection so I can send it to my controller?

asked Aug 9, 2010 at 12:27
4
  • 2
    Your code seems to be fine, what are you expecting? Commented Aug 9, 2010 at 12:32
  • What's a "collection", by your definition? Commented Aug 9, 2010 at 12:33
  • Ya, do you mean that you want a collection to be passed into your server side handler? OR some sort of JavaScript controller? Commented Aug 9, 2010 at 12:57
  • @ Everyone -- I think I got what I was looking for. I guess I was just thinking way too much. So what I did was with the code sample provided above, I was able to get the ids: "1,2,3,etc." I pass that variable "addNew" as a parameter to serverside where I create another variable "colAddNew = addNew.Split(',')" to put it in a collection. I then iterate through and was able to get to where I want to be. Commented Aug 9, 2010 at 13:04

1 Answer 1

1

you can do this...

var v_coll=[];
$('#divListBox').find(':checked').each(function(){
 v_coll.push($(this).val);
});
answered Aug 9, 2010 at 13:15
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.