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
hersh
1,1832 gold badges13 silver badges26 bronze badges
-
2Your code seems to be fine, what are you expecting?Sarfraz– Sarfraz2010年08月09日 12:32:35 +00:00Commented Aug 9, 2010 at 12:32
-
What's a "collection", by your definition?Tomalak– Tomalak2010年08月09日 12:33:29 +00:00Commented 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?Java Drinker– Java Drinker2010年08月09日 12:57:01 +00:00Commented 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.hersh– hersh2010年08月09日 13:04:52 +00:00Commented Aug 9, 2010 at 13:04
1 Answer 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
Kratz
7765 gold badges11 silver badges17 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js