title: JavaScript not working in ASP.NET MVC with EF
body: <p>I am trying to wire up a button with some web app using the click method but it's not working. The JS on the rest of my web site is working fine but this does not seem to like me.</p>
  <p>I am new to ASP.NET and I am working using a tutorial so if anything is done in a certain way it's because that's how it's done in tutorial. Here is my code of the page that is creating the problem, I will implement the function javascript how calculate montantbrut = courn + courm + cours</p>
  <p>Create razor view :</p>
  <pre><code>&lt;h2&gt;Create&lt;/h2&gt;
  &lt;div class=&quot;form-horizontal&quot;&gt;
      &lt;h4&gt;Coordonnee&lt;/h4&gt;
      &lt;hr /&gt;
      @Html.ValidationSummary(true, &quot;&quot;, new { @class = &quot;text-danger&quot; })
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.EnseignantId, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.EnseignantId, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.EnseignantId, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Nom, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Nom, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Nom, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Specialite, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.DropDownListFor(model =&gt; model.Specialite, new SelectList(ViewBag.list), &quot;إختر إختصاص &quot;,htmlAttributes:new { @class = &quot;form-control&quot; })
              @Html.ValidationMessageFor(model =&gt; model.Specialite, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Rang, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.DropDownListFor(model =&gt; model.Rang, new SelectList(ViewBag.list), &quot;إختر رتبة &quot;, htmlAttributes: new { @class = &quot;form-control&quot; })
              @Html.ValidationMessageFor(model =&gt; model.Rang, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Courn, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Courn, new { htmlAttributes = new { @class = &quot;form-control&quot; },,@id=&quot;courn&quot; })
              @Html.ValidationMessageFor(model =&gt; model.Courn, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tdn, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tdn, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tdn, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tpn, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tpn, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tpn, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Courm, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Courm, new { htmlAttributes = new { @class = &quot;form-control&quot; },@id=&quot;courm&quot; })
              @Html.ValidationMessageFor(model =&gt; model.Courm, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tdm, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tdm, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tdm, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tpm, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tpm, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tpm, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Cours, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Cours, new { htmlAttributes = new { @class = &quot;form-control&quot; } ,,@id=&quot;cours&quot;})
              @Html.ValidationMessageFor(model =&gt; model.Cours, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tds, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tds, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tds, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tps, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tps, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tps, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Montantbrut, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Montantbrut, new { htmlAttributes = new { @class = &quot;form-control&quot; },@id=&quot;montanbrut&quot; })
              @Html.ValidationMessageFor(model =&gt; model.Montantbrut, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Tva, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Tva, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Tva, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Montantnet, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Montantnet, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Montantnet, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          &lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
              &lt;input type=&quot;submit&quot; value=&quot;Create&quot; class=&quot;btn btn-primary&quot; onClick=&quot;savebtn&quot; /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>And Javascript code :</p>
  <pre><code>@section scripts {
  
  &lt;script type=&quot;text/javascript&quot;&gt;
  
  $(document).ready(function(){
  
      $('courn').change(function () {
  
          $('montantbrut').val = $('courn').val + $('courm').val+ $('cours').val;
          alert(&quot;test de click&quot;);
      });
  });
  &lt;/script&gt;
  </code></pre>