我正在處理一個小項目,其中包含一個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:
 
我不知道怎麼解決這個問題,是以請幫我。