function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chirugantachiruganta 

selectall checkbox problem

hi every one,

i dont know java script much,

here i used check box,

if i select top most one , it selects all options but the problem is if i unselect any one of the option, the top most check box should be unselected,

please help,

 

<script>
  function checkAll(cb)
  {
 var inputElem = document.getElementsByTagName("input");
  for(var i=0; i<inputElem.length; i++)
  {
  if(inputElem[i].id.indexOf("checkedone")!=-1)
  inputElem[i].checked = cb.checked;
  }
  }   
  </script>

Taiki YoshikawaTaiki Yoshikawa

Hi,

 

hope this is thing you are looking for.
 
All Check Script Sample
<script>
 function allcheck(prmListSize) {
  var hederElement = document.getElementById('pageId:formId:blockId:hederId');
  var listSize = prmListSize;
  var columnElement;

  if(hederElement.checked){
   for(i=0;i < listSize; i++){
    columnElement = document.getElementById('pageId:formId:blockId:tableId:' + i +':colId');
    columnElement.checked = true;
   }
 }else{
  for(i=0; i < listSize; i++){
   columnElement = document.getElementById('pageId:formId:blockId:tableId:' + i +':colId');
   columnElement.checked = false;
  }
 }
 return false;
}
</script>

 

<apex:page id="pageId">
 <apex:form id="formId">
  <apex:pageBlock id ="blockId">
   <table>
    <tr>
     <td>
      <apex:inputCheckbox value="{!headerCheck}" onClick="allcheck('{!listSize}');" id="hederId" />
     </td>
    </tr>
    <apex:repeat value="{!lists}" var="lists" id="tableId">
    <tr>
     <td>
      <apex:inputCheckbox value="{!lists.checked}"id="colId" />
     </td>
    </tr>
   </apex:repeat>
   </table>
  </apex:pageBlock>
 </apex:form>
</apex:page>

 

Regards,