You need to sign in to do that
Don't have an account?

How to check all the checkboxes in a page by clicking on a checkbox using javascript?
In a visual force page, when i click one checkbox, i need to check all the other checkboxes in a page which are created by using select options.
This is the code which i tried. I assigned true value to the selectCheckboxes id.But it was working.
Please provide me the solution.
Code:
<apex:inputCheckBox id="chkbox" onclick="var checkboxvalue=document.getElementById('{!$Component.Acctlist}').value;if(this.checked) checkboxvalue=true;"/> <b><apex:outputlabel value="Check All the Accounts" style="font-weight:normal"></apex:outputlabel></b><br/><br/> <apex:selectCheckboxes value="{!AccountsList}" id="Acctlist" layout="pageDirection"> <apex:selectOptions value="{!AccountList}"></apex:selectOptions> </apex:selectCheckboxes><br/>
This is the code which i tried. I assigned true value to the selectCheckboxes id.But it was working.
Please provide me the solution.
<apex:inputCheckBox id="chkbox" onclick="var checkbox=document.getElementById('{!$Component.select_state}');if(this.checked) checkbox.value=true;"/> <font face="calibri" size="3"><b>Select State :</b></font>
<apex:selectCheckboxes value="{!states}" style="width:150px;align:Left;background-color: #fff;border-style: solid;border-color:#D2691E;border-width:2px" id="select_state" layout="pageDirection">
<apex:SelectOptions value="{!AttStates}" />
<apex:actionsupport event="onchange" rerender="select_dist,child_blocks"/>
</apex:selectCheckboxes>