I need to create an array of the id's from each <input type="checkbox"> in a selected div.
HTML
<div id="ADC-Designer-CAD">
<table>
<tr>
<td>Teamcenter Completed:</td>
<td><input type="checkbox" id="tc" onChange="mtcb()" /></td>
<td><input type="button" id="tc" class="btn btn-default"onClick="ScrollToKP();" /></td>
</tr>
<tr>
<td>NX Manager Completed:</td>
<td><input type="checkbox" id="nxm" onChange="mtcb()" /></td>
<td><input type="button" id="nxm" class="btn btn-default"onClick="ScrollToKP();" /></td>
</tr>
</table>
</div>
There are multiple div's like this one with different id's to them. My code selects the div first. I can get it to filter the correct div. I can't get it to create the array of the check box id's inside that div.
JavaScript
$.get('content/page.php', function(data) {
data1 = $(data).filter('#' + actSite + '-' + actUT + '-CAD');
data2 = $(data1).filter(`*Not sure what to put here*`);
});
data1 works as it should and gets from <table>...</table> I need something to end looking like
data1 = ["tc", "nxm", ...]
If I were to create an array for each item I need an array for, it would take weeks. I need to be able to change the data in data1 over and over again.
EDIT / SOLUTION - 4/21/2015
I have changed all my ID's for the checkboxes as many have commented. Here is my WORKING code:
var NewArray = [];
$(':checkbox').each(function(index, element) {
NewArray.push(this.id);
});
//results NewArray = [ADC-Designer-CAD-tc,ADC-Designer-CAD-nxm,....]
tcandnxm.tcand a checkbox with the same ID