title: Check checkboxes on condition with jQuery and Struts2
body: <p>I have the following code in my JSP:</p>
  
  <pre><code>&lt;div class="fieldset_medium_right"&gt;
      &lt;div class="checkSoc"&gt;
          &lt;s:checkbox name="soc" cssClass="delete"  /&gt;            
      &lt;/div&gt;
      &lt;div class="checkEnt"&gt;
          &lt;s:checkbox name="ent" cssClass="delete"  /&gt;            
      &lt;/div&gt;
      &lt;div class="CheckUnit"&gt;
          &lt;s:checkbox name="ua" cssClass="delete" /&gt;          
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Now I would like that when I check "soc", then "ent" and "ua" become checked too, and inactive.
  Also when I uncheck "soc", then "ent" and "ua" become unchecked too, and active.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$("#soc").on('change', function() {
      var ent =   $('input[name=ent]');
      var ua = $('input[name=ua]');
  
      if ($(this).attr('checked')) {
          ent.attr('checked',true);
          ent.attr('disabled', true);
          ua.attr('checked',true);
          ua.attr('disabled', true);
        } else {
            ent.attr('disabled',false);
            ent.attr('checked',false); 
            ua.attr('disabled',false);
            ua.attr('checked',false); 
        }
  }); 
  </code></pre>
  
  <p>which doesnt work but I cant figure out how to make it be fine (beginner in Jquery here).</p>
  
  <p>I tried to inspire from a code that I adapted and made work that is:</p>
  
  <p>Edit: the following code works fine, it does what I want. However I dont know how to adapt it for my own case (ie the code which is above) because I dont have a class attribute, so I would like to use the id and also have some variables to make it look better. Hope this makes it clearer.</p>
  
  <pre><code>&lt;div class="elements"&gt;
   &lt;div class="class3"&gt;
   &lt;input class="class1" type="checkbox" value="1" name="first" id="first" /&gt;
   &lt;/div&gt;
   &lt;div class="class3"&gt;
   &lt;input class="class2" type="checkbox" value="1" name="second" id="second" /&gt;
   &lt;/div&gt;
    &lt;div class="class3"&gt;
   &lt;input class="class4" type="checkbox" value="1" name="third" id="third" /&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>$('input:checkbox.class1').live('change', function () {
  
    //if the 2nd checkbox is always class2:
    var two = $(this).parents('.elements').first().find('input:checkbox.class2');
  
    var three = $(this).parents('.elements').first().find('input:checkbox.class4');
  
    if ($(this).attr('checked')) {
      two.attr('checked',true);
        two.attr('disabled', true);
       three.attr('checked',true);
      three.attr('disabled', true);
    } else {
        two.attr('disabled',false);
       two.attr('checked',false); 
      three.attr('disabled',false);
       three.attr('checked',false); 
    }
  
  
  });
  </code></pre>
  
  <p>However with Struts it seems that there are no attributes class for the <code>&lt;s:checkbox&gt;</code> ,  so I dont know how to proceed. Any idea?</p>
  
  <p>Thank you in advance!</p>