views:

89

answers:

2

Hi, I'm loading a web page that has a series of 20+ checkboxes. The page is being loaded with data from a database, so that some of the checkboxes will be checked, and textareas connected to those checkboxes will have some text in them. What I think I want to do is: 1) iterate through all the chekboxes and find the ones that are checked 2) then modify the 'disabled' attribute and css properties of each related textarea

Each checkbox has a unique ID (for example, specA01, specA02, specA03, etc...) and each textarea has a unique but related ID (for example, specA01summ, specA02summ, specA03summ, etc...)

I have this code that I modified from another line on the same page, but I know I'm misunderstanding some basic principle here... probably has to do with the ".this" line...

    $("input[type=checkbox][checked]").each(
            function() {
                var checkBoxId = $(this).attr('id');
                $('#' + checkBoxId + 'summ').removeAttr("disabled");
                $('#' + checkBoxId + 'summ').css({'background-color' : '#ffffff', 'color' : '#000000', 'border-color' : '#696FA3', 'height' : '10em'});
                $('#' + checkBoxId + 'summRequired').css("display", "block");

            });

Essentially, in this code, I'm trying to loop through all checked checkboxes, get each of their ID's in a variable called 'checkBoxID', and then modify the textarea element with the ID of '#' + checkBoxId + 'summ' .Any help or guidance you can provide is very much appreciated. Sorry for my blatant ignorance. I'm still learning programming and jQuery.

+1  A: 
$(":checkbox:checked").each(function(o){
  var chkID = $(this).attr("id");
  $("#"+chkID+"summ").removeAttr("disabled");
  /* ... */
});
Jonathan Sampson
Thanks Jonathan, I think that did it! I was having trouble at first, but after moving some thigns around on my side, it looks like its running on page load. Now I just have to test with it connecting to the database and loading with the data. Wish me luck.
pumablues
Good work, pumablues!
Jonathan Sampson
A: 
    $(function()
    {
     // write your codes here
      // this will happen after page load
    });
Praveen Prasad