Reputation: 13844
In this fiddle,There is a to
button.
When the to
button is pressed a pop up appears with a drop down menu.
From the drop down menu a user either selects users
or groups
then a table with check boxed rows appear.
Now, after selecting a few check boxes and hitting the ok
button, the selected check boxes name should be displayed in the textfield
.
I am doing this like this:
$('#mytable tr').find('input[type="checkbox"]:checked').each(function(i)
{
sCheckbox.push($(this).attr("data-id"));
//alert("hello " +sCheckbox);
But its not working.
I added an alert
, but still, the alert is not showing which means the control is not going inside.
Please tell me how to do this.
Upvotes: 0
Views: 169
Reputation: 6693
You're reading from the wrong table. Your selector specifies #groupsTable (for instance), but the groups table in the modal has no id on it. Your selector is reading the checkboxes from the main page instead.
You can either add ids to your tables in the modal div, or use these selectors instead:
$('#ToOk').click(function(){
$('#users tr').find('input[type="checkbox"]:checked').each(function(i) {
sCheckbox.push($(this).attr("data-id"));
//alert("hello " +sCheckbox);
});
$('#groups tr').find('input[type="checkbox"]:checked').each(function(i) {
sCheckbox.push($(this).attr("data-id"));
//alert("hello " +sCheckbox);
});
var ds = (sCheckbox.length > 0) ? sCheckbox.join(",") : "";
alert("ds is "+ds);
});
Upvotes: 2