Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

count of comma seperated values

Swati30
Giga Expert

Kindly advice script for count the comma separated values and update in another variable.

 i have single line text contain values like 2009 , 2010, 2011 ...etc when they are entered these count has to update in another variable
ex: single line text variable1 : 2009 , 2010 , 2011

(single line text) variable4 has to update as 3

 

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi,

Please try this script.

var value = "2009 , 2010 , 2011";
var count = value.split(",").length;
alert(count);
g_form.setValue("variable4", count);

View solution in original post

2 REPLIES 2

Alikutty A
Tera Sage

Hi,

Please try this script.

var value = "2009 , 2010 , 2011";
var count = value.split(",").length;
alert(count);
g_form.setValue("variable4", count);

asifnoor
Kilo Patron

Hello Swati

do you need this on client side or server side?

In server side, here is how you can do it in BR.

var val = current.variables.var1.toString();

val = val.split(",");

current.variables.var4=val.length;

For client side, you can use the code provided by Ali.