I'm having a field of picklist say field1 and a field NetAmount in page1....In page2 Whenever i change the value of picklist corresponding NetAmount Should display...
My page and class
Field1
<apex:outputPanel styleClass="requiredInput" layout="block" >
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:selectlist value="{!Selectin}" size="1" >
<apex:selectoptions value="{!selectname}" />
</apex:selectlist>
</apex:outputpanel>
<apex:outputlabel value="Payment Terms"/>
<apex:outputtext value="{!payment.Net__c}"/>
public object__c payment{get;set;}
string Selectin;
Public string getSelectin(){return Selectin;}
public void setSelectin(string selectin){this.selectin = Selectin;}
public list<selectoption> getselectname()
{
list<selectoption> option = new list<selectoption>();
for(object__c invoice : [select id,name from object__c limit 10] )
option.add(new selectoption(invoice.name,invoice.name));
return option;
}
public const(){
payment = [select Net__c from object__c limit 1];
}
Attribution to: eagerinsf
Possible Suggestion/Solution #1
There's a few ways to do this, but the way I'd handle it is to have an actionsupport on the selectlist that invokes an action method to update the payment.Net__c field. Something along the lines of:
<apex:selectlist value="{!Selectin}" size="1" >
<apex:selectoptions value="{!selectname}" />
<apex:actionSupport event="onchange" action="{!updateNet}" rerender="net"/>
</apex:selectlist>
<apex:outputPanel id="net">
<apex:outputlabel value="Payment Terms"/>
<apex:outputtext value="{!payment.Net__c}"/>
</apex:outputPanel
and then in the controller:
public void updateNet()
{
List<Net__c> nets=[select Net__c from Object__c where name=:selectIn];
if (nets.size()>0)
{
payment.Net__c=nets[0].Net__c;
}
}
This assumes that the net__c record can be retrieved via the selected name 'selectIn'- if not, you'll need to adjust this to carry out the appropriate selection/calculation.
Attribution to: Bob Buzzard
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/3603