Checkbox: <input type="checkbox" id="myCheck" onclick="myFunction()">
<p id="text" style="display:none">Checkbox is CHECKED!</p>
function myFunction() {
// Get the checkbox
var checkBox = document.getElementById("myCheck");
// Get the output text
var text = document.getElementById("text");
// If the checkbox is checked, display the output text
if (checkBox.checked == true){
text.style.display = "block";
} else {
text.style.display = "none";
}
}
Arkadaşlar yukarıdaki örneği w3 ten aldım da, şimdi table içindeki td ler for döngüsünde benim. her x te th-td leri döndürüyor table için. ama bu check yapıldığında sadece ilk td işlev görüyor. diğerleri görmüyor. Başka offline pc de çalışmam olduğu için burada bu şekilde yazabildim. Umarım anlatabilmişimdir. Nasıl diğer td lere checked olduğunda yazı yazmasını sağlarım.
Evet çalışıyor fakat table içindeki for döngüsü içinde tr>th>td ler var. bu tr lerin sadece ilkinde check yapıldığında istediğim yazıyı alabiliyorum. diğer altındaki tr lerde çalışmıyor.
for x in missions:
tr
th
td0
td (İlk for döngüsünde çalışıyor. diğer oluşturulan tr lerde çalışmıyor checkbox.
<!DOCTYPE html>
<html>
<body>
<p>Display some text when the checkbox is checked:</p>
<label for="myCheck">Checkbox:</label>
<input type="checkbox" id="myCheck" onclick="myFunction()">
<input type="checkbox" id="myCheck" onclick="myFunction()">
<input type="checkbox" id="myCheck" onclick="myFunction()">
<p id="text" style="display:none">Checkbox is CHECKED!</p>
<script>
function myFunction() {
var checkBox = document.getElementById("myCheck");
var text = document.getElementById("text");
if (checkBox.checked == true){
text.style.display = "block";
} else {
text.style.display = "none";
}
}
</script>
</body>
</html>
Örneğin yukarıdaki inputlar veritabanından for döngüsü ile tablodaki -tr- deki (yani satırdaki) -td- lere (sütunlara) ekleniyor. Daha açık olamam herhalde:). Yukarıdaki kodda ilk inputtan sonrakiler çalışmaz mesela