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

Question

Question

Multiply 2 Fields

asked on April 14, 2016 Show version history

Hi!  I'm just getting started with Forms and wondered if someone had some Javascript handy to multiply 2 fields; currency x number = currency.  (rate * miles = reimburse).   Any assistance would be appreciated!  

(Yes.. I've read the "getting started with javascript" page.. it's just not sinking in fast enough for me.)

Here's what I have so far by piecing together some other examples; 

01$(document).ready(function () {
02 
03$('form').click(function(){
04 
05$('.miles').on('blur', 'input', calculate);
06 
07function calculate() {
08var miles = '[id^=Field82\\(]';
09var rate = '[id^=Field83\\(]';
10var reimburse = '[id^=Field84\\(]';
11 
12 
13reimburse = parseNumber($(this).find('.rate input').val()) * parseNumber($(this).find('.miles input').val());
14 
15      $('.reimburse input').val(reimburse);
16   
17function parseNumber(n) {
18   
19    var f = parseFloat(n); //Convert to float number.
20   
21    return isNaN(f) ? 0 : f; //treat invalid input as 0;
22   
23  }
24});

 

0 0

Replies

replied on April 14, 2016

If you have Forms 10, and you are not in a table and these are just single fields?  You may be able to use the built in Calculation field.  Go to your field that will be your "Total" and click on the Advanced area

Should be able to use =PRODUCT(field1,field2) just replace field1 and field2 with the fields you are looking to multiply.

0 0
replied on September 4, 2018

Can this be used for multiplying fields in a table?

 

For example, I want to have the multiplication calculation in the reimbursement column to be Rate Per Mile x Miles. 

0 0
replied on September 19, 2018

I am doing this exact same process, yet the example you listed above doesnt seem to work.  I do have a fixed field that is not editable. any help would be appreciated.

0 0
replied on April 14, 2016

We're in 9 for some reason... don't remember why.  

 

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

Sign in to reply to this post.