<apex:page controller="Apexclassforaccandcheck">
        <apex:dataTable value="{!acw}" var="aa">
            <apex:column><apex:inputCheckbox rendered="true" value="{!aa.checked}">
                <apex:outputText value="{!aa.nam}"/></apex:inputCheckbox>


public class Apexclassforaccandcheck{
Public List<Account> acc{set;get;}
Public List<accwrap> acw{set;get;}
Public Apexclassforaccandcheck() {
    acc=[select id,name,phone from account];
    acw=new List<accwrap>();
    for(Account a:acc){
        acw.add(new accwrap(a.name,a.id));
Public class accwrap{
    Public String nam{set;get;}
    Public String ids{set;get;}
    Public Boolean checked{set;get;}
    Public accwrap(String n,String i){

whine i click on text checkbox should enable

whine i click on text checkbox should enable


You can use html label and for attribute as below.

<label for="{!$Component['cbox']}">{!aa.nam}</label>
<apex:inputCheckbox id="cbox" rendered="true" value="{!aa.checked}">

Label for and checkbox id should match. Since visualforce changes Id attribute at runtime we use $Component to get that id.

  • visualforce page throwing error "Literal value is required for attribute id in <apex:inputCheckbox> in Apexclassforaccandcheckvf " error in <apex:inputCheckbox id="{!aa.ids}" rendered="true" value="{!aa.checked}"/>`
    – SFDC V
    Jul 27 '19 at 7:09
  • Changed answer. This actually works but have to check for repeat Jul 27 '19 at 7:22
  • thank you some mutch it working perfectly
    – SFDC V
    Jul 27 '19 at 7:38
  • Pls mark as solved if solved Jul 27 '19 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.