0
<script type="text/javascript">
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;
}
</script>
<p>Number of weekly mailings @Html.TextBoxFor(m => m.WeeklyMailings, new { id = "weeklymailing", onblur = "return:compute('txtpostcardperweek', 'weeklymailing')" }) x 25</p>
<p>=</p>
<p>@Html.TextBoxFor(m => m.PostcardsperWeek, new Dictionary<string, object>() { {"id", "txtpostcardperweek"}, { "readonly", "true" } }) Total postcards per week</p>
我需要使用一個文本框的onblur來計算用戶輸入的值爲25,並將結果顯示在下面的文本框中。我將如何傳遞onblur事件中的文本框值?在javascript中爲MVC計算函數
謝謝Darin。我使用了第二個選項。非常感謝。 – bladerunner 2011-02-11 21:26:54