Reputation: 10964
For each element returned by
{! followers }
one checkbox is created. I have a submit button, and 'on Submit' I want to record which checkboxes are and are not checked.
<apex:repeat value="{! followers }" var="follower">
$('#attendees').append(
$('<div>').css('display','inline').append(
$('<input>', {type:"checkbox"}).addClass('myCheckBox').attr('id', '{! follower.subscriberId }')
).append(
$('<label>').text('{! follower.Subscriber.Name }')
)
);
</apex:repeat>
How would I pass the values from these check boxes to the submit button? I just want to alert() or console.log() them once they reach the submit button.
Something like this maybe?
if ($('.myCheckBox').is(':checked')){
alert($('.myCheckBox').attr(???))
};
Or this?
if ($('#attendees input').is(':checked')){
alert($('#attendees input').attr('???'))
};
Upvotes: 0
Views: 83
Reputation: 104775
You can get a full list of values inside an array using the .map()
function:
var cbValues = $(".myCheckBox").map(function() {
return this.checked;
}).get();
Upvotes: 2