title: calculate function in javascript for MVC
body: <pre><code>&lt;script type="text/javascript"&gt;
  function compute(calcval, val)
  {
      var txtweeklyMailing = Number(document.getElementById(val).value);
      var total = txtweeklyMailing * 25;
      var _total = total.toFixed(2);
      var _stotal = _total + '';
      document.getElementById(calcval).value = _stotal;
      }
  &lt;/script&gt;   
  &lt;p&gt;Number of weekly mailings @Html.TextBoxFor(m =&gt; m.WeeklyMailings, new { id = "weeklymailing", onblur = "return:compute('txtpostcardperweek', 'weeklymailing')" }) x 25&lt;/p&gt;
  &lt;p&gt;=&lt;/p&gt;
  &lt;p&gt;@Html.TextBoxFor(m =&gt; m.PostcardsperWeek, new Dictionary&lt;string, object&gt;() { {"id", "txtpostcardperweek"}, { "readonly", "true" } }) Total postcards per week&lt;/p&gt;
  </code></pre>
  
  <p>I would need to use an onblur for a textbox to calculate what a user would enter by 25 and display the result in a textbox below. How would i pass in the textbox values in the onblur event? </p>