Page 1 of 1

Update display field on form

Posted: Sun Apr 03, 2016 7:58 pm
by vinaduro
Hi there,

I've been trying to get this done for a couple of hours now, but for the life of me I can't figure out how.

I have 2 fields on a form that the user would complete e.g. Leads, Sales. These are saved to the database, and when the record is requested again, I set up a display field that calculates the difference between the 2 e.g. Leads - Sales = Deficit.
What I would like to do, is be able to create the Deficit field on the form, so that once the user has filled in the Leads and Sales fields, the Deficit field will automatically be filled with the difference between the 2.

Thank you for any assistance.

Vinaduro

Re: Update display field on form

Posted: Mon Apr 11, 2016 6:40 am
by admin
vinaduro,

You could create some JavaScript to do this..

Code: Select all

function test(){

   var a = $('#fielda').val();
   var b = $('#fieldb').val();

   $('#fieldc').val(a - b);

}

and put an onchange event on both fielda and fieldb that runs test()


Steven