title: ASP.NET MVC Button.Click Not working with javascript
body: <p>I have a form that requires user input with two buttons: one button to <code>submit</code> the form values and the other button is to load a <code>partial view</code>. I'm not sure if my approach here is correct though. The <code>submit</code> button works perfectly fine however clicking the button with <code>GenerateBtn</code> id does not fire the <code>DisplayProposal()</code> function that loads the <code>partial view</code>. Any idea to solve or a better approach??</p>
  
  <pre><code>@using (Html.BeginForm())
  {
  @Html.AntiForgeryToken()
  
  &lt;div class="form-horizontal"&gt;
      &lt;h4&gt;Proposal&lt;/h4&gt;
      &lt;hr /&gt;
      @Html.ValidationSummary("", new { @class = "text-danger" })
      @Html.HiddenFor(model =&gt; model.id)
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.item, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.item, new { htmlAttributes = new { @class = "form-control" } })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;h2&gt;Generated Questions&lt;/h2&gt;
      &lt;div id="ProposalTable"&gt;&lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          &lt;div class="col-md-offset-2 col-md-10"&gt;
              &lt;input type="submit" value="Save" class="btn btn-default" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
      &lt;div class="col-md-offset-2 col-md-10"&gt;
          &lt;input type="button" value="Generate" class="btn btn-default" id="GenerateBtn" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  }
  
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  
  &lt;script&gt;
      document.getElementById("GenerateBtn").onclick = function () { DisplayProposal() };
      function DisplayProposal() {
          //Loads Partial View to &lt;div&gt;ProposalTable&lt;/div&gt;
          $('ProposalTable').load('@Url.Action("LoadStuff", "Proposals")');
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>}</p>