Reputation: 5
i made a checklist of some products to be selected for which i am using jquery to get the values the problem is the code i am using is working in jquery 1.7.2 but not working in jquery 1.9.1 . the error i get is on wrong syntax being used .
var output = jQuery.map($(':checkbox[name=vendor\[\]]:checked'), function(n, i){
return n.value;
}).join(',');
The html format is
<p><input type="checkbox" name="vendor[]" value="Event Venue">
<label for="eventvenue">Event Venue</label></p>
<p><input type="checkbox" name="vendor[]" value="Decorations & Rentals">
<label for="decorations">Decorations & Rentals</label></p>
<p><input type="checkbox" name="vendor[]" value="Florist">
<label for="florist">Florist</label></p>
Upvotes: 0
Views: 346
Reputation: 4539
Try this
var output = jQuery.map($(':checkbox[name^=vendor]:checked'), function(n, i){
return n.value;
}).join(',');
Upvotes: 0
Reputation: 388416
Try
var output = jQuery.map($(':checkbox[name="vendor[]"]:checked'), function(n, i){
return n.value;
}).join(',');
Demo: Fiddle
Upvotes: 1