Home >Web Front-end >HTML Tutorial >I have a very simple question_html/css_WEB-ITnose

I have a very simple question_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:57:111095browse

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?

100db36a723c770d327fc0aef2ce13b1
3f1c4e4b6b16bbbd69b2ee476dc4f83a
function aa()
{
ck=document.getElementById("ck")
if(ck.checked) {
document.all.t1.disabled=false
}
else{
document.all.t1.disabled=true
}
}
2cacc6d41bbb37262a98f745aa00fbf0

6c04bd5ca3fcae76e30b72ad730ca86d
0ffef6177e6bad2280e0954be81c30f6
7e788ff568e9bd64ad5ac4a7b3e522fd
36cc49f0c466276486e50c850b7e4956
6eac519e8537e4205ddd37e30a7b548a


Reply to discussion (solution)

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.



What is account ban? ?

<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>  



This is correct, thank you

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>
6c04bd5ca3fcae76e30b72ad730ca86d

64c75b158be24228c78e0ffaf8c711f7
a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c5b5ef2cbc4d4cb2fa4c87c6c3b0967e1b90dd5946f0946207856a8a37f441edf
b6c5a531a458a2e790c1fd6421739d1c9df9a8d95f34e4c11e71345e805f9e58b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5
a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1cb1681047aa65ab168cdb64da71129b3db90dd5946f0946207856a8a37f441edf
b6c5a531a458a2e790c1fd6421739d1c9e3ce5d386e93b1fd095bbf8b466ae8fb90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5
a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c90e75425bca5f94faf93727033b11cf6b90dd5946f0946207856a8a37f441edf
b6c5a531a458a2e790c1fd6421739d1c786fe22cfcb841754ed81ecce1e8af85b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5
f16b1740fad44fb09bfe928bcc527e08
36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e

onchange="aa();"

You see there is a ban in this

onchange="aa();"

You see there is a ban in this


Got it, thank you
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn