Reputation: 115
I have the following code where I would like the values of each of the checkboxes to be added to a list. I'm not sure of the correct syntax for this, any help would be appreciated. This what I am thinking of:
var = lstCheckedDefects;
$("#defectsModal .defect_selection:checked").each(function(){
lstCheckedDefects = lstCheckedDefects + ($(this).attr("value"))
});
ok how do I use the solution in an ajax post I have this code but not able to send the lstCheckedDefects as a list:
$.ajax({
type: "POST",
url:"index.cfm?action=claim.update_claim_qa_defect",
cache: false,
data:{
claim_id: claim_id,
row_id: row_id,
code_def: code_def,
defect_selection: lstCheckedDefects
},
success:function(result){
}});
Many thanks
JC
Upvotes: 0
Views: 52
Reputation: 2085
I think you're looking for something more like this:
var lstCheckedDefects = [];
$("#defectsModal .defect_selection:checked").each(function( index, element ){
lstCheckedDefects.push($(element).val());
});
Upvotes: 1