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
Santosh SSantosh S 

Need in Help in multiplying values in Two Fields

Request help in multiplying values in Two  Fields (UnitPrice__c  & QuantitySold__c}

& display the value in edit mode in 3rd Field (TotalSale__c)

 

All the 03 Fields are  Number type

 

 -----------------------------------VF Page------------------------------------------------------------------------------
               
  <apex:inputField id="IDUnitPrice" value="{!opportunity.UnitPrice__c}" ></apex:inputField>
  <apex:inputField id="IDQtySold" value="{!opportunity.QuantitySold__c}"  onkeyup="javascript&colon;CalculateAmount();">  

  </apex:inputField>
  <apex:inputField id="IDTotalSale" label="Total Sale" value="{!opportunity.TotalSale__c}"></apex:inputField>
 ------------------------------------Script -----------------------------------------------------------------------------------

function CalculateAmount()
      {  
        
         var Price =  VALUE(UnitPrice__c.);
         var Qty = VALUE(QuantitySold__c);
         
         var Amount =  Price * Qty;      
      
         VALUE(TotalSale__c) = Amount;
      }
         

Best Answer chosen by Admin (Salesforce Developers) 
Suresh RaghuramSuresh Raghuram

function CalculateAmount()
      {  
        
         var Price =  '{!opportunity.UnitPrice__c}';
         var Qty = '{!opportunity.QuantitySold__c}';

         var TotSal = '{!opportunity.TotalSale__c};


         
         var Amount =  Price * Qty;      
      
          TotSal = Amount;
      }

If this answers your question make this as a solution.