title: how to convert javaScript array into string And store in Hidden field in MVC?
body: <p>onclick Function:-</p>
  
  <p></p>
  
  <pre><code>    //$(document).ready(function() {
  AddRemoveCustomer = function(){
      var CustomerIDArray =[];
      $(".checkBoxClass").click(function(e) {
          var arr = CustomerIDArray;
          var checkedId =$(this).attr('id');
          if ($(this).prop('checked')){
              CustomerIDArray.push(checkedId);
              arr = CustomerIDArray;
          }
          else
          {
              jQuery.each(CustomerIDArray, function(i, item){
                  if (arr[i] == checkedId)
                  {
                      arr.splice(i, 1);
                  }
              });
              CustomerIDArray = arr;
          }
          var ids = "";
          jQuery.each(CustomerIDArray, function(i, item){
              if (ids == "")
              {
                  ids = CustomerIDArray[i];
              }
              else
              {
                  ids = ids + "," + CustomerIDArray[i];
              }
          });
          alert(ids);
      });;
      };
      &lt;/script&gt;
  </code></pre>
  
  <p>View:-</p>
  
  <pre><code>&lt;table id="tblEmailScheduler"  class="table-bordered col-offset-12"&gt;
              &lt;thead&gt;
                  &lt;tr class="label-primary"&gt;
                      &lt;th style="padding:5px 15px;"&gt;
                          First Name
                      &lt;/th&gt;
                      &lt;th style="padding:5px 15px;"&gt;
                          Last Name
                      &lt;/th&gt;
                      &lt;th style="padding:5px 15px;"&gt;
                          Email ID
                      &lt;/th&gt;
                      &lt;th style="padding:5px 15px;"&gt;
                          Customer Type
                      &lt;/th&gt;
                      &lt;th style="padding:5px 15px;"&gt;
                          Customer Designation
                          @Html.DropDownList("CustomerDesignation", new SelectList(ViewBag.SelectAllCustomerDesignationDDL, "Value", "Text"), new { id = "CustomerDesignationDDL" , name = "CustomerDesignationDDL" })
                      &lt;/th&gt;
                      &lt;th style="padding:5px 15px;"&gt;
                          Select All
                          &lt;div class="checkbox control-group"&gt;
                              &lt;label&gt;
                                  &lt;input type="checkbox" id="cbSelectAll" /&gt;
                              &lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/th&gt;
  
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tfoot&gt;
                  &lt;tr&gt;
                      &lt;th colspan="2"&gt;
                          EmailTemplate :
                          @Html.DropDownList("EmailSubject", new SelectList(ViewBag.SelectAllEmailTemplateDDL, "Value", "Text"), new { id = "SelectAllEmailTemplateDDL" })
                      &lt;/th&gt;
                      &lt;th colspan="2"&gt;
                          Set Date And Time:
                          &lt;input type="text" class = "from-date-picker" readonly = "readonly"  /&gt;
                      &lt;/th&gt;
                      &lt;th colspan="2"&gt;
                         &lt;input type="submit" value="Schedule" id="btnSubmit" class="btn btn-default" /&gt;
                      &lt;/th&gt;
                      &lt;td&gt;
  
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tfoot&gt;
              @foreach (var item in Model)
              {
                  &lt;tr style="text-align:center"&gt;
                      &lt;td id="tblFirstName"&gt;
                          @item.FirstName
                      &lt;/td&gt;
                      &lt;td id="tblLastName"&gt;
                          @item.LastName
                      &lt;/td&gt;
                      &lt;td id="tblEmailID"&gt;
                          @item.EmailID
                      &lt;/td&gt;
                      &lt;td id="tblCustomerType"&gt;
                          @item.CustomerType
                      &lt;/td&gt;
                      &lt;td id="tblCustomerDesignation"&gt;
                          @item.CustomerDesignation
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class="checkbox control-group"&gt;
                              &lt;label&gt;
                                  &lt;input type="checkbox" id="@item.CustomerID" value="@item.CustomerID"  onclick="AddRemoveCustomer()" class="checkBoxClass"/&gt;
                                  @*@Html.CheckBox("Select", new { id = "cbCustomer", item.CustomerID})*@
                              &lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
        &lt;/table&gt;
          &lt;input type="hidden" id="hfCustomerID"/&gt;
  </code></pre>
  
  <ol>
  <li>I have given checkbox as i check checkbox value of row stored in array in JavaScript.</li>
  <li>I want to convert JavaScript array into string and it should save in hidden field.</li>
  <li>When I click on paging then hidden field value should load in array and then in array it also stores the new checked value with existing value from hidden field</li>
  </ol>