我不断收到一条错误消息,显示未捕获类型错误:无法设置未定义的“值”属性。我知道它指的是波纹管代码中的dienumber,我理解错误的含义,但在这种情况下感到困惑。我的随机数会产生问题吗?谢谢!
function roll() {
var dienumber = 12;
dienumber = Math.floor((Math.random() * 6) + 1);
wintotal = document.JForm.totalpoints.value;
var p1curr = 0;
var p2curr = 0;
p1current = document.JForm.p1turn.value;
p2current = document.JForm.p2turn.value;
if (dienumber != 1) {
p1curr = parseFloat(p1current) + (dienumber);
p2curr = parseFloat(p2current) + (dienumber);
} else {
p1curr = 0;
p2curr = 0;
}
if (P1 == 1) {
document.JForm.p1turn.value = p1curr;
document.JForm.p2turn.value = "0";
} else {
document.JForm.p1turn.value = "0";
document.JForm.p2turn.value = p2curr;
}
if (dienumber == 1) {
turn_counter = turn_counter + 1;
if (P1 == 1) {
P1 = 2;
P2 = 1;
} else {
P1 = 1;
P2 = 2;
}
}
document.JForm.dienum.value = dienumber;