Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  91] [ 2]  / answers: 1 / hits: 19599  / 12 Years ago, fri, december 7, 2012, 12:00:00

I have a checkbox that is unchecked by default and a disabled input by default.



<label class=checkbox span3><input type=checkbox> I am a full-time student.</label>
<input class=inputIcon span3 id=disabledInput type=text placeholder=Enter School Name disabled>


I have full control over the class and id names and the site uses jQuery so can use that or plain javascript if needed.



If a user checks the box, then the disabled attribute should be removed from the following input. If the user unchecks it should become disabled again.



Found a several similar questions on StackOverflow but none seem to be this exact use case.


More From » jquery

 Answers
3

You have to assign id to checkbox to bind the click to particular checkbox,



Live Demo



<input type=checkbox id=chk>

$(#chk).click(function(){
$(#disabledInput).attr('disabled', !this.checked)
});

[#81564] Thursday, December 6, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sandra

Total Points: 708
Total Questions: 100
Total Answers: 84

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
sandra questions
Tue, Jun 30, 20, 00:00, 4 Years ago
Sun, May 31, 20, 00:00, 4 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
Fri, May 31, 19, 00:00, 5 Years ago
;