我有下面的代碼,我似乎無法弄清楚爲什麼它不工作。如何在複選框被選中時更新文本框?
JS小提琴:http://jsfiddle.net/EQHRV/
的JavaScript:
function hourmin() {
if (document.getElementById('hourmin').checked == 1){
document.getElementById('total').value = "01:00";
}else{
document.getElementById('total').value = "00:00";
}
}
HTML:
<p>Total Time: <BR><input type="text" style="width:95%;" id="total" name="total" value="" readonly="readonly"/>
<input type="checkbox" id="hourmin" name="hourmin" onclick="hourmin();">Pay Hour Minimum?
什麼是錯誤您收到?我把它放在代碼和它的工作:http://codepen.io/anon/pen/FblhA – sCaRy1337
JSFiddle + Firebug報告'hourmin'不是一個函數。有趣。 – naththedeveloper
@FDL使用Pure JS和no-wrap(head)配置它,它按預期工作。 –