-1
我只是不能想出辦法:(計算與獨立的結果
嘗試了很多的組合,只是在唯一錯誤結束了
我試圖做到這一點的是: - 2行。的複選框 第1行包含值的複選框:
<input onclick="clickCh(this)" type="checkbox" name="row1" value="1">
行2包含具有值的複選框:
<input onclick="clickCh(this)" type="checkbox" name="row2" value="2">
,導致:
<input id="row1" type="text" name="total"> Row one results.
<input id="row2" type="text" name="total"> Row two results.
<input id="total" type="text" name="total"> Row one and two results combined.
腳本使用:
var total = document.getElementById("total")
function clickCh(caller){
if(caller.checked){
add(caller)
} else {
subtract(caller)
}
}
function add(caller){ total.value = total.value*1 + caller.value*1}
function subtract(caller){ total.value = total.value*1 - caller.value*1}
腳本本身是不是我的,我只是覺得這個網站
getelementbyid後的冒號? –
我在那裏看不到問題。文中任何地方缺少問號都支持我的理論...... – John3136
-2行復選框? – Brilliand