Expand my Community achievements bar.

Polulating a numeric field from a drop down list with its value

Avatar

Former Community Member
OK. I am new here and I have tried to search for this answer. I am trying to populate a numeric field from a drop down list. I associated values with my drop down list and I want that value to be in the numeric field.



I have it working to the point that the field fills in but always with zero not the actual number associated with the drop down list.



I put this in under CHANGE in the drop down list.



numericfield1.rawValue =xfa.event.newText;



I also tried newValue instead of newText but it did the same thing.



Any suggestions?



Also can I call the numeric field (i.e.) n3? I am totalling all of the sums and I named them all n1, n2, etc...... It doesn't seem to like the name.



Also one more issue. I want to check a check box and have a value fill in the numeric field. How do I do this.



Thanks. I can send my form to you if you need it. Any help is appreciated.



I love the program but dont know code but learning.
1 Reply

Avatar

Level 6
Hi Charles,



If you assign something that isn't a number to a numeric field, it shows you a zero. The rawValue from a drop down is a string, so you need to cast it to a number. Try using the JavaScript ParseInt function. The second parameter is the radix (base 10). Something like:



var strNumberishString = xfa.event.newText;

var nIntegerThing = parseInt(strNumberishString,10);

oNumericField.rawValue = nIntegerThing;



I hope that works for you.



Jared Langdon

J. Langdon Consulting

www.jlangdon.ca