title: How can i use a variable created within a view as an argument within an action result? (ASP.NET MVC)
body: <p>Within my view i have a piece of JavaScript where i have declared a variable ' Fk '</p>
  
  <pre><code>&lt;script&gt;
       function test(clickedID) 
       {
            var Fk = clickedID;                        
       }
  &lt;/script&gt;
  </code></pre>
  
  <p>I want to be able to use 'Fk' within an action result by passing it as a parameter.
  For example:</p>
  
  <pre><code>[HttpPost]
          public ActionResult ReadFk(int Fk) //i would imagine id pass Fk to the ActionResult through the use of its paramaters..?
          {
              var dataFileFk = Server.MapPath("~/App_Data/ForeignKeyValue.txt");
  
              var textFileDataFk = Fk + Environment.NewLine;
  
              System.IO.File.WriteAllText(dataFileFk, textFileDataFk);
  
              return View();
          }
  </code></pre>
  
  <p>Is there an easy way of doing this?
  Thank you!</p>