Requirements: a checkbox and a text. When the checkbox is selected, the text can be edited, and when the checkbox is not selected, the text cannot be edited.
The following code does not respond to the text when the checkbox is selected/unselected. What is the problem?
<script> <br> function aa() <br> { <br> ck=document.getElementById("ck") <br> if(ck.checked) { <br> document.all.t1.disabled=false <br> } <br> else{ <br> document.all.t1.disabled=true <br> } <br> } <br> </script>
Is there any problem? Isn’t your writing very good?
document.getElementById("ck") Use this more often.
No matter how you write code, your account will not be banned. After you finish writing a sentence of code, you need to seal it.
<html><script>function aa(){ck=document.getElementById("ck")t1=document.getElementById("t1")if(ck.checked){t1.disabled="" }else{t1.disabled="disabled"}}</script><body><input type="text" id="t1" disabled="disabled"><input id="ck" type="checkbox" onchange="aa();" ></body></HTML>
document.getElementById("ck") Use this frequently.
No matter how you write code, you won’t get banned. After you finish writing a sentence of code, you need to seal it.
<html><script>function aa(){ck=document.getElementById("ck")t1=document.getElementById("t1")if(ck.checked){t1.disabled="" }else{t1.disabled="disabled"}}</script><body><input type="text" id="t1" disabled="disabled"><input id="ck" type="checkbox" onchange="aa();" ></body></HTML>
Follow the above question
There are 3 checkboxes in the first column of the table, each checkbox Followed by a text
Still required: When the checkbox is selected, the text behind it is editable, and when it is not selected, the text behind it is not editable
Can only one aa() be used in the script at this time? How to write it?
Note that the names of the three checkboxes are the same, and the names of the three texts are also the same
html>