ShowAll Questionssorted byDate Posted
Santosh 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;
}

Suresh Raghuram

function CalculateAmount()
{

var Price =  '{!opportunity.UnitPrice__c}';
var Qty = '{!opportunity.QuantitySold__c}';

var TotSal = '{!opportunity.TotalSale__c};

var Amount =  Price * Qty;

TotSal = Amount;
}