0
一个非常简单的表,一个单元格需要一个数字,第二个(只读) 即时显示该数字的两倍。但是,有些东西是行不通的。什么也没有发生:JS - onkeyup(动态计算)
HTML:
<td><input type="text" id="qantity" name="qantity" onkeyup="getValues()"
class="number" value="" autofocus placeholder="0"
onfocus="this.placeholder = ''"
onblur="this.placeholder = '0'"
onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
</input></td>
<td id="total" name="total" class="right">0.00</td>
JS:
<script>
function getValues(){
var var_qantity = Number(document.getElementById("qantity").value);
var var_total = var_qantity * 2;
document.getElementById("total").value = var_total;
}
</script>
谢谢Gopalkrishna !!。问题解决了。 –