javscript 修改代码 统计以下值是0的个数 var sel1 = document.getElementById("s50").value; var sel2 = document.getElementById("s11").value; var sel3 = document.getElementById("s12").value; var sel4 = document.getElementById("s14").value; var sel5 = document.getElementById("s51").value; var sel6 = document.getElementById("s19").value; var sel7 = document.getElementById("s20").value; var sel8 = document.getElementById("s21").value; var sel9 = document.getElementById("s22").value; var sel10 = document.getElementById("s23").value; var sel11 = document.getElementById("s24").value; var sel12 = document.getElementById("s25").value; var sel13 = document.getElementById("s26").value; var sel14 = document.getElementById("s27").value; var sel15 = document.getElementById("s28").value; var sel16 = document.getElementById("s52").value; var sel17 = document.getElementById("s40").value; var sel18 = document.getElementById("s41").value; var sel19 = document.getElementById("s42").value; var sel20 = document.getElementById("s46").value; var sel21 = document.getElementById("s53").value;
时间: 2023-12-25 11:40:18 浏览: 96
你可以使用以下的JavaScript代码来统计这些值为0的个数:
```javascript
var sel1 = document.getElementById("s50").value;
var sel2 = document.getElementById("s11").value;
var sel3 = document.getElementById("s12").value;
var sel4 = document.getElementById("s14").value;
var sel5 = document.getElementById("s51").value;
var sel6 = document.getElementById("s19").value;
var sel7 = document.getElementById("s20").value;
var sel8 = document.getElementById("s21").value;
var sel9 = document.getElementById("s22").value;
var sel10 = document.getElementById("s23").value;
var sel11 = document.getElementById("s24").value;
var sel12 = document.getElementById("s25").value;
var sel13 = document.getElementById("s26").value;
var sel14 = document.getElementById("s27").value;
var sel15 = document.getElementById("s28").value;
var sel16 = document.getElementById("s52").value;
var sel17 = document.getElementById("s40").value;
var sel18 = document.getElementById("s41").value;
var sel19 = document.getElementById("s42").value;
var sel20 = document.getElementById("s46").value;
var sel21 = document.getElementById("s53").value;
var count = 0;
if (sel1 == 0) {
count++;
}
if (sel2 == 0) {
count++;
}
if (sel3 == 0) {
count++;
}
if (sel4 == 0) {
count++;
}
if (sel5 == 0) {
count++;
}
if (sel6 == 0) {
count++;
}
if (sel7 == 0) {
count++;
}
if (sel8 == 0) {
count++;
}
if (sel9 == 0) {
count++;
}
if (sel10 == 0) {
count++;
}
if (sel11 == 0) {
count++;
}
if (sel12 == 0) {
count++;
}
if (sel13 == 0) {
count++;
}
if (sel14 == 0) {
count++;
}
if (sel15 == 0) {
count++;
}
if (sel16 == 0) {
count++;
}
if (sel17 == 0) {
count++;
}
if (sel18 == 0) {
count++;
}
if (sel19 == 0) {
count++;
}
if (sel20 == 0) {
count++;
}
if (sel21 == 0) {
count++;
}
if (count > 0) {
console.log("不合格");
} else {
console.log("合格");
}
```
上述代码会遍历每个选择框的值,通过逐个判断是否为0来统计个数。最后根据个数的结果输出"不合格"或"合格"。你可以将这段代码添加到你的JavaScript文件中,或者直接在浏览器的开发者工具中执行。
阅读全文