Instead of using a table, I have the following HTML showing a checkbox in col 1, a name in col 2, and an EMail address in col 3. The HTML looks like this:
<div class="rowLight">
<div class="select"><input name="checkbox" id="chk1" class="chktbl" type="checkbox"></div>
<div class="name">Mary</div><div class="emayl">Mary@ABC.com</div>
</div>
<div class="rowDeep">
<div class="select"><input name="checkbox" id="chk2" class="chktbl" type="checkbox"></div>
<div class="name">Jerry</div><div class="emayl">Jerry@ABC.net</div>
</div>
I need to iterate through each checkbox, and it the box is checked, capture the name & Email address that will be sent to a webservice which will populate an EMail table. I tried something like this, but need help…
var vals = [];
$('.select input[type="checkbox"]:checked').each(function(i) {
var name = $(this).next('.name');
vals.push(($(name).html());
var emayl = $(this).next('.emayl');
vals.push(($(emayl).html()); });
Thanx,
Jerry
Something like this could work:
Note that the data will look like:
Example: http://jsfiddle.net/andrewwhitaker/rMPDH/
If you truly want the data in just an array:
You could try:
Example: http://jsfiddle.net/andrewwhitaker/4GdC8/
Notes:
.mapto take a jQuery result and transform it into the data you need..get()at the end of the.mapcall forces the resulting object into a proper array (as opposed to a jQuery object).closest(),.next(), and.siblings()to retrieve the proper data.