<script type="text/javascript">
$(function () {
var CustomerIDArray=[];
$('#tblEmailScheduler').find('input[type="checkbox"]:checked').each(function (i,item) {
//how to Add checked id's in array??
});
});
});
</script>
<table id="tblEmailScheduler" class="table-bordered col-offset-12">
<thead>
<tr class="label-primary">
<th style="padding:5px 15px;">
First Name
</th>
<th style="padding:5px 15px;">
Last Name
</th>
<th style="padding:5px 15px;">
Email ID
</th>
<th style="padding:5px 15px;">
Customer Type
</th>
<th style="padding:5px 15px;">
Customer Designation
@Html.DropDownList("CustomerDesignation", new SelectList(ViewBag.SelectAllCustomerDesignationDDL, "Value", "Text"), new { id = "CustomerDesignationDDL" , name = "CustomerDesignationDDL" })
</th>
<th style="padding:5px 15px;">
Select All
<div class="checkbox control-group">
<label>
<input type="checkbox" id="cbSelectAll" />
</label>
</div>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th colspan="2">
EmailTemplate :
@Html.DropDownList("EmailSubject", new SelectList(ViewBag.SelectAllEmailTemplateDDL, "Value", "Text"), new { id = "SelectAllEmailTemplateDDL" })
</th>
<th colspan="2">
Set Date And Time:
<input type="text" class = "from-date-picker" readonly = "readonly" />
</th>
<th colspan="2">
<input type="submit" value="Schedule" id="btnSubmit" class="btn btn-default" />
</th>
<td>
</td>
</tr>
</tfoot>
@foreach (var item in Model)
{
<tr style="text-align:center">
<td id="tblFirstName">
@item.FirstName
</td>
<td id="tblLastName">
@item.LastName
</td>
<td id="tblEmailID">
@item.EmailID
</td>
<td id="tblCustomerType">
@item.CustomerType
</td>
<td id="tblCustomerDesignation">
@item.CustomerDesignation
</td>
<td>
<div class="checkbox control-group">
<label>
<input type="checkbox" id="cbCustomer" value="@item.CustomerID" class="checkBoxClass"/>
</label>
</div>
</td>
</tr>
}
</table>
This is my code. in this Foreach generated checkbox for each row. I want to create array in java script. When I check specific row then that row CustomerID should add in function and when i unchecked specific row then it should removed from array.