HOME ➔ SUPPORT ➔ Community ➔ General CourseLab issues ... Variables - Text or String ?
Variables - Text or String ?
  View type:
I am trying to do the following:

I have 3 drop down boxes, each having values 1,2,3,4&5 (of which the user can select any one).

For e.g. the user may select 3 from the first drop down, 4 from the second & 5 from the third.

I want a sum of all the three selected values. i.e. I want 12 as the sum.

However, when I try to sum them up using the formula #var1+#var2+#var3, I get a concatenation of strings rather than the addition of numbers. i.e. my answer is 345 instead of 12.

Am I doing something wrong ?? Or is course lab configured to return only strings from the drop down....??
 
Hi, Dominic!
In fact, it is a bug and it is fixed in 2.4 versions that will be available soon. While it is not available, you can use this workaround: instead of
#var + #var2 +...
use
parseInt(#var1) + parseInt(#var2) + ...
(or parseInt(#var1,10) - the same syntax with radix specified). Expression will be evaluated as number in this case.
 
 
Thanks a lot for the prompt response Slav!

Courselab is real cool!

Thanks again!
Subject:
Message options
No additional options