You are viewing limited content. For full access, please sign in.

Question

Question

Calcutaing Colums in Forms

asked on May 8, 2016

I am in need of some help.

I have to colums I need to add together(CSS class names are "h_extrastotals" & "extrastotals"). I need to do a Sum calculation to get the combined total of these colums into a total extras colum (CSS Class name "Extrastotaltotals". There might be more than one row for each of these calsses. Please see image below.

Equipment Details
            Model*    Serial Number    Gross Sales Price    Settlement Value    Payout    MDS Fee    Extras Total    
Device 1    

    
Add another Model
Software Details
            Select Software Product*    Select Product Type    Select Product    Unit Cost    Quantity    Gross Sales Price    Extras Total    
Software 1    
    

    
Add More Software
Rental Amount Verify
Gross Total
Extras Total
Finance Amount Total

0 0

Replies

replied on May 9, 2016

If using Forms 9.?, you require JavaScript.

If using Forms 10.1 you can use the built in Calculation features which is easier than coding (for some of us:).

What version of Forms are you using?

0 0
replied on May 9, 2016

I was able to get assistance from laserfiche support and was able to solve this using scripts. I am currently using Forms 10.1. But for some reason the calculation feature just did not give me the correct results. below is the script I used to get it working.

$(document).ready(function(){
var figArray = [];
$("#calcsums").click(function calculate() {
    figArray.length = 0;
    calcSums();
   });

 function calcSums(){
        $(function (){
            
             $(".hardware tbody tr").each(function allRows(){
             var rowId = $(this).find("td:first").text().replace(/^\D+|\r\n|\n|\r|\D+/g, '');
             var fieldVal=$(document.getElementById('Field85(' + rowId + ')')).val();
             var fieldNum=Number(fieldVal);
             
             alert("hardware Row number: " + rowId + " has a value of: " + fieldNum);            
             figArray.push(fieldNum);    
              });
              
               $(".software tbody tr").each(function allRows(){
             var rowId = $(this).find("td:first").text().replace(/^\D+|\r\n|\n|\r|\D+/g, '');
             var fieldVal=$(document.getElementById('Field85(' + rowId + ')')).val();
             var fieldNum=Number(fieldVal);
             
             alert("software Row number: " + rowId + " has a value of: " + fieldNum);            
             figArray.push(fieldNum);    
              });
              
              });
            
   
                   var sum = figArray .reduce(function(a,b){return a+b;},0);
            
                alert("Result: " + sum);
 
                   $('.grosstotaltotals input').val(sum);
};
});

0 0
replied on May 9, 2016

I'd be interested in seeing your form, since v10 i've used their calculator option as a mainstay.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.