我正在处理一个小项目,其中包含一个PHP页面,该页面将要求用户为测试输入一些问题,然后在编写一个数字(例如10)后,他将为每种类型的考试分配问题数(加、减、乘、除),直到问题数完成,例如,在选择10到他可以在乘法中选择5个加法,在乘法中选择3个加法,在除法中选择2个加法,但是他不能分配更多的问题,因为总共10个问题已经完成了。他在HTML中的数字输入类型中分配这些数字,所以我想得到第一个输入类型,即问题总数,然后每次他增加任何一种考试类型(添加,…)时,将该数字递减,当它达到0时,将禁用输入类型,如下所示:
var numInput = document.getElementById('numInput');
var Input1 = document.getElementById('Input1');
var Input2 = document.getElementById('Input2');
var Input3 = document.getElementById('Input3');
var Input4 = document.getElementById('Input4');
Input1.disabled = true;
Input2.disabled = true;
Input3.disabled = true;
Input4.disabled = true;
var Checker = setInterval(function Checker() {
var numValue = numInput.value;
//thats what I tried to do to solve my problem but it didn't work properly because it must decrement only 1 but the condition will still be true so it will decrement for ever or at least that is what I think.
if (Input1.value > 0) {
numValue = numValue - 1;
}
//and this part is working fine.
if (numValue > 0) {
Input1.disabled = false;
Input2.disabled = false;
Input3.disabled = false;
Input4.disabled = false;
} else if (numValue <= 0) {
Input1.disabled = true;
Input2.disabled = true;
Input3.disabled = true;
Input4.disabled = true;
}
}, 100);
How many questions do you want to answer?
Addition:
 
Subtraction:
 
Multiplication:
 
Division:
 
我不知道怎么解决这个问题,所以请帮我。