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
finalistfinalist 

Formatting numeric s-controls

I have an s-control that calculates a fee based on whether a [x] checkbox is checked, and the default formatting displays the result with 3-decimal precision.  It also displays in a larger font than the rest of the page, and with a white background.

I added some css code intended to bring the (Contract) page's stylesheets into play for the font and background, but I really am more interested in the number format for now.

Currently the s-control is displaying the formula directly, i.e. I do not have a javascript function doing the calculation.  I tried that, but my only experience with functions inside s-controls is something that requires a link to be clicked, and in this case I want the number to appear without any further action by the client/user.

Here's the code (the js function is there, but it's not being called (as you can see)):

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<link href="/dCSS/Theme2/default/common.css" type="text/css"
media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css"
media="handheld,print,projection,screen,tty,tv" rel="stylesheet">
<HTML>
<!-- HEAD>
<script>
function resizeframe(){ 

sframe=top.document.getElementById("NCPD_Fee"); 
sframe.style.height=document.body.clientHeight + "px";

}
 
function calcNCPDFee(){
        // calcNCPDFee calculates 3% * Contract Amount if the NCPD Fee checkbox is checked

           var ncpd_fee = {!IF(Contract.NCPD_Member__c, (Contract.Amount__c  * 0.03), 0)};
           ncpd_fee.toFixed(2);

}
</script>
</HEAD -->
<BODY class="contract">
<!-- DIV class="bPageBlock secondaryPalette" -->
<DIV class="pbBody">
<DIV class="pbSubsection" -->
<TABLE class="detailList">
<TR>
<TD class="labelCol">

// Here is where the calculation is actually being displayed:
NCPD Fee: {!IF(Contract.NCPD_Member__c, (Contract.Amount__c * 0.03), 0)}
</TD> </TR> </TABLE> </DIV> </DIV> <!-- /DIV --> </BODY> </HTML>

Any thoughts?  Thanks!

SnardSnard
Hi,

Maybe I don't understand the usage of your s-control, but wouldn't it be easier to use a custom SFDC calculated field to do this?

  - Mike
finalistfinalist
Okay, you got me.  That's what I get for overthinking the problem.

(I knew I shouldn't have skipped over that part of the tutorial...dang!)

Thanks for being polite about it at least.