Expand my Community achievements bar.

i want to apply % from a drop down menu to my numerical field

Avatar

Former Community Member
I have stuggled through a simple addition, subtraction and tax percentage box on simple field boxes, but now i need4 drop down field boxes with serveral percentages adding to a total field. anybody any samples they could upload with scripts.??
2 Replies

Avatar

Former Community Member
I don't have an example handy but the concept is pretty simple and maybe you can work through it from there. One way to do it would be to have each of the drop down boxes have a change event that recalculates the total based on the values in the boxes.



For example (JavaScript code):



NumericField2.rawValue = parseInt(NumericField1.rawValue) * (parseInt(xfa.event.newText) + parseInt(DropDownList2.rawValue));



If you put code like this in the change handler for the drop-down lists, then NumericField2 would get set to the value of NumericField1 times the sum of the two drop down lists.



The parseInt function takes the string value from the combo box and converts it into an integer value so you can use it in mathematical expressions.



Notice that for the field whose change event this is, rather than using it's rawValue, you have to use xfa.event.newText to get the new value for the field.



Hope this helps..

--

SteveX

Adobe Systems