0

The TotalValue__c field being calculated on the fly/client side while the user is entering the field values and and so that they don’t have to do the calculation themselves.

TotalValue__c = ((Revenue1__c + Revenue2__c)*Term__c) + Fee1__c + Fee2__c .

Visualforce Page

<apex:page controller="examplecontroller" sidebar="false" tabStyle="Opportunity" >

<apex:form id="newform">

 <apex:sectionHeader Title="Example"  />

   <apex:outputPanel id="addRender" >
    <apex:repeat value="{!serlin}" var="s" id="theRepeat">            
    <apex:pageBlock id="block1">

     <apex:pageBlockSection collapsible="true" showHeader="true" title="Service" id="section1">               

                <apex:inputfield value="{!s.Revenue1__c}" required="true"/>
                <apex:inputField value="{!s.Revenue2__c}" required="true"/>
                <apex:inputField value="{!s.Fee1__c}"  required="true"/>
                <apex:inputField value="{!s.Fee2__c}" required="true"/>
                <apex:inputField value="{!s.Term__c}" required="true"  />
                <apex:inputField value="{!s.TotalValue__c}" required="true" />

    </apex:pageBlockSection> 


</apex:pageBlock>       
</apex:repeat> 
</apex:outputPanel>

</apex:form>

Controller

public with sharing class examplecontroller {


public LIst<example__c> serlin {get;set;}
public String OpportunityId{get;set;}



public examplecontroller() 
{
    try{

        serlin = new list<Service_Line__c>();
        OpportunityId =ApexPages.currentPage().getParameters().get('id');

        if(OpportunityId != null && OpportunityId != '') 
        {

            serlin =  [SELECT Id,Revenue1__c,Revenue2__c,Fee1__c,Fee2__c,Term__c,TotalValue__c FROM example__c WHERE Opportunity__c =:OpportunityId];
            System.debug('serlinlst:'+serlin);

        }
    } catch(Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    } 

}

}

what is best way to achieve this one using jquery or javascript or visualforce components?

Thanks Nagarjuna

3
  • What is the question? Is something throwing an error? It doesn't look like you have any logic currently in your code to handle this. Is the Total_Contract_Value__c going to be stored in Salesforce? Is this something better done in Javascript? Commented Jul 14, 2014 at 10:44
  • 1
    This Update Total with Javascript has a JavaScript answer and a Salesforce re-render answer that if you are not comfortable with JavaScript and don't mind a small time delay is probably a better way to go. Commented Jul 14, 2014 at 10:51
  • @nagarjuna Cool. I've copied the comment to an answer; marking that as the accepted answer will avoid others looking to help you even though you have figured it out. Commented Jul 14, 2014 at 13:30

1 Answer 1

1

This Update Total with Javascript has a JavaScript answer and a Salesforce re-render answer that if you are not comfortable with JavaScript and don't mind a small time delay is probably a better way to go.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.