我用兩個文本框來概括號,但顯示錯誤..未捕獲的ReferenceError:txtMaking_F沒有定義
<script>
function getPrice(tMaking, tHandeling, tTotal) {
var obj_tMaking = document.getElementById(txtMaking_F)
var obj_tHandeling = document.getElementById(txtHandeling_F)
var obj_tTotal = document.getElementById(txtTotal_F)
if (obj_tMaking.value != "" && obj_tHandeling.value != "") {
obj_tTotal.value = parseInt(obj_tMaking.value) + parseInt(obj_tHandeling.value);
}
else {
obj_tTotal.value = "";
}
}
</script>
</head>
<body>
<input name="grdView$ctl08$txtMaking_F" type="text" id="grdView_ctl08_txtMaking_F" class="classMaking" onchange="javascript:return getPrice('grdView_ctl08_txtMaking_F','grdView_ctl08_txtHandeling_F','grdView_ctl08_txtTotal_F');" style="width: 60px;" />
<input name="grdView$ctl08$txtHandeling_F" type="text" id="grdView_ctl08_txtHandeling_F" class="classHandling" onchange="javascript:return getPrice('grdView_ctl08_txtMaking_F','grdView_ctl08_txtHandeling_F','grdView_ctl08_txtTotal_F');" style="width: 60px;" />
<input name="grdView$ctl08$txtTotal_F" type="text" id="grdView_ctl08_txtTotal_F" class="classTotal" style="width: 100px;" />
</body>
你的問題是什麼?你不明白這個錯誤嗎?這意味着變量'txtMaking_F'沒有被定義。 –
謝謝我犯了一個愚蠢的錯誤 – Nisar