tags:

views:

32

answers:

1

I am having rich:dataTable inside that many div elements are defined. Each div element is having h:selectBooleanCheckbox and some number of input boxes. How to clear those input boxes only if checkbox is not checked. My sample code snippet

<rich:dataTable>
 <div id="#1">
  <h:selectBooleanCheckbox value=""/>
  <h:inputText value=""/>
  <h:inputText value=""/>
 </div>

 <div id="#2">
  <h:selectBooleanCheckbox value=""/>
  <h:inputText value=""/>      
 </div>
</rich:dataTable>
+1  A: 

This jQuery snippet should work for you, it will clear the values of all the text boxes if the checkbox next to them is unchecked within the same DIV.

       $("div :checkbox:not(:checked)").each(function () {
            $(this).siblings(":text").val("");
        });
ace