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
Release: 2016-06-24 11:57:11
Original
1128 people have browsed it

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>






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>  
Copy after login
Copy after login

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>  
Copy after login
Copy after login



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>

















onchange="aa();"
Copy after login
Copy after login

You see there is a ban in this

onchange="aa();"
Copy after login
Copy after login

You see there is a ban in this


Got it, thank you
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template