如何在使用javascript禁用其他输入之前启用所有输入?
在函数laisviLaikai()中,我试图在选择日期时禁用检查输入,它工作正常,但当我更改日期时,这些输入仍然被禁用 所以我写了一个代码来处理这个问题。调用函数时,代码必须启用所有检查输入,但它不工作 这是我的Html代码:如何在使用javascript禁用其他输入之前启用所有输入?,javascript,html,Javascript,Html,在函数laisviLaikai()中,我试图在选择日期时禁用检查输入,它工作正常,但当我更改日期时,这些输入仍然被禁用 所以我写了一个代码来处理这个问题。调用函数时,代码必须启用所有检查输入,但它不工作 这是我的Html代码: <form> <input type="text" id="datepicker"> <input type="button" value="tikrinti" onclick="laisviLaikai()">
<form>
<input type="text" id="datepicker">
<input type="button" value="tikrinti" onclick="laisviLaikai()">
<div class="radio">
<h2>Pasirinkite laiką</h2><br>
<input type="radio" name="pas-laikas" id="10-00">
<label for="10-00"><span class="select" id="10-00-2">10:00</span></label>
<input type="radio" name="pas-laikas" id="10-15">
<label for="10-15"><span class="select" id="10-15-2">10:15</span></label>
<input type="radio" name="pas-laikas" id="10-30">
<label for="10-30"><span class="select" id="10-30-2">10:30</span></label>
<input type="radio" name="pas-laikas" id="10-45">
<label for="10-45"><span class="select" id="10-45-2">10:45</span></label>
<input type="radio" name="pas-laikas" id="11-00">
<label for="11-00"><span class="select" id="11-00-2">11:00</span></label>
<input type="radio" name="pas-laikas" id="11-15">
<label for="11-15"><span class="select" id="11-15-2">11:15</span></label>
<input type="radio" name="pas-laikas" id="11-30">
<label for="11-30"><span class="select" id="11-30-2">11:30</span></label>
<input type="radio" name="pas-laikas" id="11-45">
<label for="11-45"><span class="select" id="11-45-2">11:45</span></label>
<input type="radio" name="pas-laikas" id="12-00">
<label for="12-00"><span class="select" id="12-00-2">12:00</span></label>
<input type="radio" name="pas-laikas" id="12-15">
<label for="12-15"><span class="select" id="12-15-2">12:15</span></label>
<input type="radio" name="pas-laikas" id="12-30">
<label for="12-30"><span class="select" id="12-30-2">12:30</span></label>
<input type="radio" name="pas-laikas" id="12-45">
<label for="12-45"><span class="select" id="12-45-2">12:45</span></label>
<input type="radio" name="pas-laikas" id="13-00">
<label for="13-00"><span class="select" id="13-00-2">13:00</span></label>
<input type="radio" name="pas-laikas" id="13-15">
<label for="13-15"><span class="select" id="13-15-2">13:15</span></label>
<input type="radio" name="pas-laikas" id="13-30">
<label for="13-30"><span class="select" id="13-30-2">13:30</span></label>
<input type="radio" name="pas-laikas" id="13-45">
<label for="13-45"><span class="select" id="13-45-2">13:45</span></label>
<input type="radio" name="pas-laikas" id="14-00">
<label for="14-00"><span class="select" id="14-00-2">14:00</span></label>
<input type="radio" name="pas-laikas" id="14-15">
<label for="14-15"><span class="select" id="14-15-2">14:15</span></label>
<input type="radio" name="pas-laikas" id="14-30">
<label for="14-30"><span class="select" id="14-30-2">14:30</span></label>
<input type="radio" name="pas-laikas" id="14-45">
<label for="14-45"><span class="select" id="14-45-2">14:45</span></label>
<input type="radio" name="pas-laikas" id="15-00">
<label for="15-00"><span class="select" id="15-00-2">15:00</span></label>
<input type="radio" name="pas-laikas" id="15-15">
<label for="15-15"><span class="select" id="15-15-2">15:15</span></label>
<input type="radio" name="pas-laikas" id="15-30">
<label for="15-30"><span class="select" id="15-30-2">15:30</span></label>
<input type="radio" name="pas-laikas" id="15-45">
<label for="15-45"><span class="select" id="15-45-2">15:45</span></label>
<input type="radio" name="pas-laikas" id="16-00">
<label for="16-00"><span class="select" id="16-00-2">16:00</span></label>
<input type="radio" name="pas-laikas" id="16-15">
<label for="16-15"><span class="select" id="16-15-2">16:15</span></label>
<input type="radio" name="pas-laikas" id="16-30">
<label for="16-30"><span class="select" id="16-30-2">16:30</span></label>
<input type="radio" name="pas-laikas" id="16-45">
<label for="16-45"><span class="select" id="16-45-2">16:45</span></label>
<input type="radio" name="pas-laikas" id="17-00">
<label for="17-00"><span class="select" id="17-00-2">17:00</span></label>
<input type="radio" name="pas-laikas" id="17-15">
<label for="17-15"><span class="select" id="17-15-2">17:15</span></label>
<input type="radio" name="pas-laikas" id="17-30">
<label for="17-30"><span class="select" id="17-30-2">17:30</span></label>
<input type="radio" name="pas-laikas" id="17-45">
<label for="17-45"><span class="select" id="17-45-2">17:45</span></label>
<input type="radio" name="pas-laikas" id="18-00">
<label for="18-00"><span class="select" id="18-00-2">18:00</span></label>
<input type="radio" name="pas-laikas" id="18-15">
<label for="18-15"><span class="select" id="18-15-2">18:15</span></label>
<input type="radio" name="pas-laikas" id="18-30">
<label for="18-30"><span class="select" id="18-30-2">18:30</span></label>
<input type="radio" name="pas-laikas" id="18-45">
<label for="18-45"><span class="select" id="18-45-2">18:45</span></label>
<input type="radio" name="pas-laikas" id="19-00">
<label for="19-00"><span class="select" id="19-00-2">19:00</span></label>
<input type="radio" name="pas-laikas" id="19-15">
<label for="19-15"><span class="select" id="19-15-2">19:15</span></label>
<input type="radio" name="pas-laikas" id="19-30">
<label for="19-30"><span class="select" id="19-30-2">19:30</span></label>
<input type="radio" name="pas-laikas" id="19-45">
<label for="19-45"><span class="select" d="19-45-2">19:45</span></label>
</div>
<input type="button" value="Registruotis" onclick="getData()">
</form>
帕西林凯特·莱克
10:00
10:15
10:30
10:45
11:00
11:15
11:30
11:45
12:00
12:15
12:30
12:45
13:00
13:15
13:30
13:45
14:00
14:15
14:30
14:45
15:00
15:15
15:30
15:45
16:00
16:15
16:30
16:45
17:00
17:15
17:30
17:45
18:00
18:15
18:30
18:45
19:00
19:15
19:30
19:45
这是我的javascript函数代码:
function laisviLaikai() {
let tikrinamaData = document.getElementById("datepicker").value;
console.log("Gaunama data is lauko " + tikrinamaData);
//Pasalina pazymetus laikus jei buvo pazymeti
let pazLaik = document.getElementsByName("pas-laikas");
for (let b = 0; b < pazLaik.length; b++) {
pazLaik[b].disabled = false;
}
let db;
let request = window.indexedDB.open("InfoDB", 1);
request.onerror = function(e) {
console.log("Klaida: " + e.target.error);
};
request.onsuccess = function (e) {
db = e.target.result;
let tran = db.transaction(["info"], "readwrite");
let objektas = tran.objectStore("info");
let ats = objektas.getAll();
ats.onsuccess = function(){
let atsakymas = ats.result;
for (let a = 0; a < atsakymas.length; a++){
if (tikrinamaData === atsakymas[a].data){
let banLaikas = atsakymas[a].laikas;
let blLaikas = document.getElementById(banLaikas);
blLaikas.disabled = true;
let inactive = document.getElementById(banLaikas+"-2");
inactive.style = "background: #969696;";
console.log("loop " + atsakymas[a].data)
}
}
}
tran.oncomplete = function(e) {
console.log("baigta");
};
}
}
函数laisviLaikai(){
让tikrinamaData=document.getElementById(“日期选择器”).value;
console.log(“Gaunama数据为lauko”+tikrinamaData);
//莱库斯热布沃帕兹梅蒂雀
让pazLaik=document.getElementsByName(“pas-laikas”);
for(设b=0;b
和必须使检查输入未禁用的功能中的代码:
let pazLaik = document.getElementsByName("pas-laikas");
for (let b = 0; b < pazLaik.length; b++) {
pazLaik[b].disabled = false;
}
let pazLaik=document.getElementsByName(“pas laikas”);
for(设b=0;b
因此,在结果中,调用此函数时,必须启用名称为“pas laikas”的所有检查输入,然后在满足其他代码中的要求时禁用。您必须按类而不是名称获取收音机
<input type="radio" class="pas-laikas" id="10-00">
您必须按类名而不是名称获取收音机
<input type="radio" class="pas-laikas" id="10-00">
这就是解决方案,代码终于可以工作了。谢谢你,麦康!这就是解决方案,代码终于可以工作了。谢谢你,麦康!