Write down Java function inside <body> and <script> tags and inside your page tag <apex:page>
The page will look like this
The page will look like this
<apex:page standardController="PV_Watts__c" id="pg" extensions="CustomRestClass"> <apex:form id="frm"> <apex:outputpanel id="outpanel" > <apex:pageBlock title="Calculate Total Production" id="pgBlock1" > <apex:pageBlockSection id="header" > <apex:commandButton value="Save" action="{!save}" id="saveButton" r
eRender="outpanel"/> </apex:pageBlockSection> <apex:pageBlockSection title="Array 1" id="pbSec1" > <apex:inputField id="A1_shade" value="{!PV_Watts__c.A1_Shade__c}"/>
<apex:outputField id="sysLoss" value="{!PV_Watts__c.PV_A1_System_Losses__c}"/><!-- java funcation is called here on onclick--> <apex:commandButton onclick="calSysLoss1(); return false;" value="Calculate System Losses"
rerender="pbSec1" / > </apex:pageBlockSection>
<!---Java function would be like this -->
<body>
<script>
function calSysLoss(){
var j$ = jQuery.noConflict() var shade=j$("[id$='A1_shade']").val(); var sysLossOutput = (( 1- ( 1 - 0.02 ) * ( ( (Discount)/100 )) * ( 1 - 0.02 ) * ( 1 - 0.02 ) * ( 1 - 0.005 ) * ( 1 - 0.015) * ( 1- 0.01 ) * ( 1 - 0.03) )* 100).toFixed(2); document.getElementById("{!$Component.frm.pgBlock1.pbSec1.sysLoss}").innerHTML=sysLossOutput;
}
</script>
</body>
Comments
Post a Comment