title: ASP.NET / MVC HTML ActionLink - how to pass returned Javascript value to ActionLink routeValue parm?
body: <p>(target framework is 4.0)</p>
  
  <p>I am implementing a feature to delete multiple records in a simple table. In order to do this, I am using simple HTML checkboxes with a Javascript function to loop through each one to find which are selected. The Javascript is returning an array of int values representing the record IDs to delete.</p>
  
  <p>I am using an ActionLink to call all of this, and to ultimately return to the Delete function (with an int array as a parm) in my controller file to actually submit the deletions to the database.</p>
  
  <p>My problem is, I don't know how to take the array I get back from the Javascript to place into the ActionLink, to pass it into the controller.</p>
  
  <p>Here is the code with which I am working:</p>
  
  <pre><code>&lt;p&gt;
      @Html.ActionLink("Add New", "Add") | @Html.ActionLink("Delete Selected", "Delete", new { id = "???" }, new { onclick = "return getProjectsToDelete()" })
  &lt;/p&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function getProjectsToDelete() {
  
      var answer = confirm("Are you sure you wish to delete the selected projects?");
  
      if (answer) {
          var listToDelete = new Array();
          var arrayCount = 0;
  
          for (i = 0; i &lt; document.projectList.deleteProject.length; i++) {
              if (document.projectList.deleteProject[i].checked) {
                  listToDelete[arrayCount] = document.projectList.deleteProject[i].value;
                  arrayCount++;
              }
          }
  
          return listToDelete;
      }
  }
  
  &lt;/script&gt;
  </code></pre>