Expand my Community achievements bar.

Populating Fields with Numeric Values

Avatar

Former Community Member
Hi,



I have a form which has a First Rental Box which our customers type in a numeric value. Next to this box is a VAT box which needs to be populate automatically. VAT is calculated by First Rental Value * 17.5 / 100. How I automatically populate the vat box with the correct value? Also, once thats been done, I have a total box which needs to be populate with First Rental + VAT?



Hope you guys can help.



David
3 Replies

Avatar

Level 5
assuming all the fields for this calculation are in the same subform you may use code similar to the following...



try the JavaScript code on the 'exit' event of the FirstRentalValue field



if (!this.isNull) {

this.parent.vat.rawValue = this.rawValue * (17.5/100);

this.parent.total.rawValue = this.raValue + this.parent.vat.rawValue;

}

Avatar

Former Community Member
SekharN, please can you explain a little more, Im not too good with this java script.



The Rental Box name is Text46, the Vat box name is Text46a and the total Box Name is Textab.



Now I know somehow once Ive filled in the first value, the javascript will then work out the vat and total and automatically populate the correct values, but how do I achieve this?



Thanks

Avatar

Former Community Member
Ok, can anyone help with this one. Ive tried to populate the fields with the relevant values but I just cant get it done. Ive now change the exit action in the script editor to do the following



FirstRentalVat = FirstRental * (17.5/100)

FirstRentalTotal = FirstRental + FirstRentalVat



Now how to I populate the VAT Box with FirstRentalVat value and like wise for the Total box to have the value of FirstRentalTotal?