• edawson
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I'd like to display a value calculated from custom fields in a visualforce page without resorting to writing a custom controller. I tried writing a javascript function with no luck. Any help would be greatly appreciated.

 

below is my code for the page. when I try to save i get the error, "Error: The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice."

 

<apex:page standardController="Property__c">
<script type="text/javascript"> 
function totalCost() {
    var price = {!Property__c.PurchPrice__c};
    var rehab = {!Property__c.TotalRehab__c};
    var totCost = price + rehab;
    return totCost;
    }
</script>
  <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="totalCost()" /></apex:outputText><br/>
</apex:page>

 

I'd like to display a value calculated from custom fields in a visualforce page without resorting to writing a custom controller. I tried writing a javascript function with no luck. Any help would be greatly appreciated.

 

below is my code for the page. when I try to save i get the error, "Error: The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice."

 

<apex:page standardController="Property__c">
<script type="text/javascript"> 
function totalCost() {
    var price = {!Property__c.PurchPrice__c};
    var rehab = {!Property__c.TotalRehab__c};
    var totCost = price + rehab;
    return totCost;
    }
</script>
  <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="totalCost()" /></apex:outputText><br/>
</apex:page>