You need to sign in to do that
Don't have an account?
Rohit Paul
Enable/Disable inputText using checkbox - ActionFuntion
Hi,
Need to have a page where the inputText field must be activated only when the checkbox next to it is tagged.
Can you please provide me an example?
Thanks.
You can use below code for reference i am changing checkbox on this you can reverse the fields
<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
Hi Rohit,
Yes this is possible but this is not a standard functionality. You have to create a visualforce page for this then you can achieve this.
Ya I already achieved to do so ....
Used actionSupport for the checkbox on the event ónChange which worked.
Rerendering the required region assisted in locking or unlocking the field but the response time is slow for field opening or closing.
Is there any method which could improve the respose time of the change?
Try the following code and if it fits you, adapt it ;)
You can use below code for reference i am changing checkbox on this you can reverse the fields
<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;
}
}
Hi Abhay,
Thanks for the example, I had already used this kind of logic for my case.
The only isse I face is the delay in field opening and closing based on checkbox.
As you understand, using JavaScript the process is much faster in basic HTML, but in Visualforce there is a delay in the responce.
Other than that the code is working just fine :)