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
aniiiiiianiiiiii 

Based on Picklist update checkbox

Hi I need an help in Vf page  i had an urgent requirement ..

i have an vf page with cutom picklist on change i need the check box to update.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Abhay AroraAbhay Arora

Hi Anii,

 here you go

 

<apex:page id="thepage" standardController="Account" extensions="testComponent">
<apex:form >
    <apex:inputField value="{!acc.AccountSource}">
        <apex:actionSupport event="onchange" action="{!changeCheckBox}" rerender="pan" status="counterStatus" />
    </apex:inputField>
            <apex:outputPanel id="pan">
            <apex:inputField id="test" value="{!acc.check__c}"/>
        </apex:outputPanel>
        <apex:actionStatus id="counterStatus" startText=" (incrementing...)" stopText=" (done)"/>
</apex:form>
</apex:page>

 

public with sharing class testComponent {

    public testComponent() {

    }

    public Account acc{get;set;}
    public testComponent(ApexPages.StandardController controller) {
        acc=[select id,AccountSource,check__c from account where id='0019000000CJ6QZ'];
    }
    public pagereference changeCheckBox(){
        acc.check__c=true;
        return null;
    }

}

 

All Answers

jd123jd123

Hi Anii

you can do  by using Workflow rule just update the check box field true when condition is  true

 

if my solution worked for you mark it as resolved.

 

Cheers

 

jd123jd123

Hi Anni 

You can write Action Support just call a method in that write true for that Checkbox and reRender.

aniiiiiianiiiiii

Hi can u send me sample code

for this

Abhay AroraAbhay Arora

Hi Anii,

 here you go

 

<apex:page id="thepage" standardController="Account" extensions="testComponent">
<apex:form >
    <apex:inputField value="{!acc.AccountSource}">
        <apex:actionSupport event="onchange" action="{!changeCheckBox}" rerender="pan" status="counterStatus" />
    </apex:inputField>
            <apex:outputPanel id="pan">
            <apex:inputField id="test" value="{!acc.check__c}"/>
        </apex:outputPanel>
        <apex:actionStatus id="counterStatus" startText=" (incrementing...)" stopText=" (done)"/>
</apex:form>
</apex:page>

 

public with sharing class testComponent {

    public testComponent() {

    }

    public Account acc{get;set;}
    public testComponent(ApexPages.StandardController controller) {
        acc=[select id,AccountSource,check__c from account where id='0019000000CJ6QZ'];
    }
    public pagereference changeCheckBox(){
        acc.check__c=true;
        return null;
    }

}

 

This was selected as the best answer
Abhay AroraAbhay Arora

please mark it as solved if above works for you