Activity Forums Salesforce® Discussions Calculation on Visualforce Page without using Controller

  • Prafull

    Member
    April 14, 2016 at 6:19 am

    $(document).ready(function(){
    var count = 0;
    count+=$(':input').length;
    count+=$("select").length;
    var datalistCount =$("datalist").length;
    count+= datalistCount;
    count+=$("textarea").length;
    $(".TotalCountOfField").val(count - 1 - datalistCount);
    });

  • Sourabh

    Member
    April 14, 2016 at 6:39 am

    Hi Gaurav,

    Another method to calculate total of your field is by using <apex:variable>.

    For example i am displaying my field in <apex:repeat>. Then i will use apex variable like this:-

    <apex:variable var="i" value="{!0.00}"/>
    <Table>
    <apex:repeat value="{!Value}" var="item">
    <tr>
    <td> {!item.FieldName}
    <apex:variable var="i" value="{!i+item.FieldName}"/>
    </td>
    </tr>

    <tr>
    <td>
    Total : {!i}
    </td>
    </apex:repeat>
    </Table>

     

    This way the total of field value will be displayed.

  • Parul

    Member
    September 18, 2018 at 6:27 am

    Create two variable and then add with '+' in third variable in apex page without any controller.

    Try this code snippet:

    <apex:page standardController="Property__c">
    <apex:outputText value="Purchase: "/><apex:outputText value="{0, number, $###,###}"><apex:param value="{!Property__c.PurchPrice__c}" /></apex:outputText><br/>
    <apex:outputText value="Rehab: "/><apex:outputText value="{0, number, $###,###}"><apex:param value="{!Property__c.TotalRehab__c}" /></apex:outputText><br/>
    <apex:outputText value="Total: "/><apex:outputText value="{0, number, $###,###}"><apex:param value="{!Property__c.PurchPrice__c + Property__c.TotalRehab__c}" /></apex:outputText><br/>
    </apex:page>

     

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos