0

I have 5 text boxes whose IDs and names are all different from each other. But i have to enable all 5 text boxes when a certain checkbox is checked. How do i do this with JavaScript?

1
  • 1
    may be this can help you. Commented Mar 13, 2011 at 8:40

1 Answer 1

3

With jQuery you can do

<input id="check" type="checkbox" value=""><br>
<input type="text" value="" disabled="disabled"><br>
<input type="text" value="" disabled="disabled"><br>
<input type="text" value="" disabled="disabled"><br>

var $input = $('input[type="text"]');
$('#check').live('click', function() {
    $(this).is(':checked') ? $input.removeAttr('disabled') : $input.attr('disabled', 'disabled');
})

Check working example at http://jsfiddle.net/CpmkE/3/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.