Get The Values From The Multiple Checkbox And Append It To Html?
I'm using the modal from twitter bootstrap, i want to make a modal that when a user click on button it appear with checkboxes that have a specific values, and when modal hide the v
Solution 1:
I think the problem is when you do allVals.push(checkbox_val);
inside the .each
loop, you are pushing the same value all the times, that's why you got [1,1,1]. So update your jQuery:
jQuery(document).ready(function($) {
$('#myModal .btn').last().on('click', function(){
varMyModal = $('#myModal');
functionget_value() {
var allVals = [];
$('input:checkbox:checked').each(function() {
allVals.push($(this).val()); //Use the $('this') selector
});
$('a.btn').after("<p>" + allVals + "</p>");
}
MyModal.modal('hide').on('hidden', function(){
get_value();
})
});
});
Post a Comment for "Get The Values From The Multiple Checkbox And Append It To Html?"