作为表单提交的一部分,我有一个如下的输入标记。
<input type=“checkbox” id=“allowcheatmode” name=allowCheatMode value=“NO” onchange=“allowCheatModes()”>
以及 JS 函数中的 allowCheatModes
function allowCheatModes(){
var x = document.getElementById(“allowcheatmode”).checked
if (x) {
document.getElementById(“allowcheatmode”).value = “YES”
} else {
document.getElementById(“allowcheatmode”).value = “NO”
}
但是,当我allowcheatmode
在表单提交后尝试打印变量时,这不起作用。我在这里做错了什么?