Creé 3 funciones de Javascript para realizar cálculos y mostrar el resultado en 3 cuadros de texto. Cuando guardo esta página y la vuelvo a abrir -> no extrae los valores calculados en los cuadros de texto respectivos a menos que mueva el mouse sobre ellos o haga clic en ellos. He usado el método window.onload con la intención de que ejecute la función cuando se abra la página. Estoy usando onKeyUp y onMouseMove event Listeners, tal vez esa sea la causa del problema. Si es así, qué detector de eventos debo usar para realizar la operación.
<div class="form-group"> @Html.Label("Admin Fee(5% of Total Amount of FNLCP Funding Used) ", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextBox("AdminFeeWorkPlan", "", "{0:c}", new { @class = "form-control", id = "calculateAdminFee", @onKeyUp = "findTotal", @onMouseMove = "findTotal()" }) <script type="text/javascript"> function AdminFeee() { var pullValue = document.getElementById('res').value || "0"; var output = (5/100) * parseFloat(pullValue); if (!isNaN(output)) { document.getElementById('calculateAdminFee').value = output; } } window.onload = AdminFeee(); </script> </div> </div> <div class="form-group"> @Html.Label("Total ", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextBox("FinalTotal", "", "{0:c}", new { @readonly="readonly", @class = "form-control", id = "calculateTotal" }) <script type="text/javascript"> function findTotal() { var one = document.getElementById('res').value || "0"; var two = document.getElementById('calculateAdminFee').value || "0"; var output2 = parseFloat(one)-parseFloat(two) ; if (!isNaN(output2)) { document.getElementById('calculateTotal').value = output2; } } window.onload = findTotal(); </script> </div> </div>