Play假装我们正在招募一支工程师团队
我们需要1-2个后端工程
2-3前端工程
1 qa eng
他们每个人都有以下属性:
域名(BE,FE,QA)
可用性(从0到1)
例如,2 eng,系数为0.5,可用性计为1 eng
例
var John = {domain:BE availability:0.7};
我需要创建一个功能,让工程师加入我的团队,或者如果团队满员则拒绝他 . 如果申请成功,则打印为TRUE,否则为FALSE .
我尝试了这个,但它没有打印任何东西,按钮不起作用
我个人认为问题出在底部的状态检查中 .
任何帮助赞赏 .
<!DOCTYPE html>
<html>
<head>
<body>
<input type="checkbox" id="1" name="BE" value="1">
<label for="1">Marko (BE)</label><br>
<input type="checkbox" id="2" name="BE" value="1">
<label for="2">Janko (BE)</label><br>
<input type="checkbox" id="3" name="BE" value="1">
<label for="3">Jovan (BE)</label><br>
<input type="checkbox" id="4" name="FE" value="1">
<label for="4">Ilija (FE)</label><br>
<input type="checkbox" id="5" name="FE" value="1">
<label for="5">Petar (FE)</label><br>
<input type="checkbox" id="6" name="FE" value="1">
<label for="6">Dusan (FE)</label><br>
<input type="checkbox" id="7" name="QA" value="1">
<label for="7">Petar (QA)</label><br>
<input type="checkbox" id="8" name="QA" value="1">
<label for="8">Lazar (QA)</label><br>
<input type="checkbox" id="9" name="QA" value="1">
<label for="9">Filip (QA)</label><br>
<script>
function a() {
var BE = 0; //back end count
var FE = 0; //font end count
var QA = 0; //qa count
var i = 0; //general purpose counter
var dostupnost = document.getElementById("1").value //availability factor
var checkBox = document.getElementById("1");
}
if (checkBox.checked == true) {
i = i + parseFloat(dostupnost);
BE++;
}
var dostupnost = document.getElementById("2").value
var checkBox = document.getElementById("2");
if (checkBox.checked == true) {
BE++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("3").value
var checkBox = document.getElementById("3");
if (checkBox.checked == true) {
BE++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("4").value
var checkBox = document.getElementById("4");
if (checkBox.checked == true) {
FE++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("5").value
var checkBox = document.getElementById("5");
if (checkBox.checked == true) {
FE++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("6").value
var checkBox = document.getElementById("6");
if (checkBox.checked == true) {
FE++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("7").value
var checkBox = document.getElementById("7");
if (checkBox.checked == true) {
QA++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("8").value
var checkBox = document.getElementById("8");
if (checkBox.checked == true) {
QA++;
i = i + parseFloat(dostupnost);
}
var dostupnost = document.getElementById("9").value
var checkBox = document.getElementById("9");
if (checkBox.checked == true) {
QA++;
i = i + parseFloat(dostupnost);
}
if (i <= 6 && BE >= 1 && BE <= 2 && FE >= 2 && BE <= 3 && QA == 1) { //me checking the conditions?
alert("True");
} else {
alert("False");
}
</script>
<button type="button" onclick="a()">Prijavi</button>
</body>
</head>
</html>