title: How to get checkbox selected value and pass to controller in asp.net mvc 4
body: <p>I am trying to get the selected checkboxes value</p>
  
  <p>this are my models,</p>
  
  <pre><code>public class VehicleViewModel : Vehicle
  {
      [Display(Name = "Vehicle Type")]
      [Required( ErrorMessage = "{0} is required.")]
      public string VehicleTypeName { get; set; }
  
      [Display(Name = "Location")]
      [Required(ErrorMessage = "{0} is required.")]
      public string LocationName { get; set; }
  
      public IEnumerable&lt;AssignProductsViewModel&gt; AssignedProducts { get; set; }
  }
  
  public class AssignProductsViewModel
  {
      public long ProductID { get; set; }
      public string ProductName { get; set; }
  }
  </code></pre>
  
  <p>here's my razor view</p>
  
  <pre><code>@foreach (var item in Model.AssignedProducts)
  {
    &lt;tr&gt;
      &lt;td&gt;
        &lt;input type="checkbox" value ="@item.ProductID"/&gt;
      &lt;/td&gt;
      &lt;td&gt;
        @Html.DisplayFor(model =&gt; item.ProductName)
      &lt;/td&gt;
    &lt;/tr&gt;
  }
  </code></pre>
  
  <p>and here's my controller</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult NewVehicle(VehicleViewModel vehicleViewModel, string selected)
  {
    //Do something with the string here
    return View();
  }
  </code></pre>
  
  <p>I know I need to pass the selected check boxes value to a string using javascript and pass the string to a controller. But i have no idea how to do it since I'm a newbie in javascript and MVC.</p>