大家好,我有總金額的代碼ParseFloat去的NaN
function computeChange(){
var change;
var amountDue = parseFloat(document.getElementById("amountDue").value);
var amountReceive = parseFloat(document.getElementById("amountReceive").value);
change = amountReceive - amountDue;
document.getElementById('amountChange').innerHTML = change;
}
<td>Total Amount</td>
<td>Php:<span id="amountDue"><?php echo $sum; ?></span></td>
</tr>
<tr>
<td>Amount Paid</td>
<td><input type="number" id="amountReceive" required="required" maxlength="4" size="4" onKeyUp="computeChange()"></td>
</tr>
<tr>
<td>Change</td>
<td>Php:<span id="amountChange"></span></td>
</tr>
是一個十進制
的支付金額輸入類型=文本
所以問題是,如果我在輸入的東西文本框的變化範圍變爲NaN
什麼被輸入到文本框? –
'amountDue'是一個'span',它沒有價值。 – zerkms
@ DanielA.White如果你輸入了AMOUNT RECEIVED,那麼它會觸發跨度到顯示值 –