How to split the field values on client script

lucky6
Tera Contributor

Hi Team,

I have created one field which contains (',') seperated values like 123,456,789 and want to display the values in below format through onload Client script in the same field.

123

456

789

Thanks in advance 

 

 

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi @lucky6 

Can you try below:

 

function onLoad() {
    //Type appropriate comment here, and begin script below  
    var getVal = g_form.getValue("u_string_full_utf8_1"); //replace with your field name
    var sp = getVal.split(",");
    for (var i = 0; i < sp.length; i++) {
        if (i == 0)
            g_form.setValue("u_string_full_utf8_1", sp[i] + "\n");
        else
            g_form.setValue("u_string_full_utf8_1", g_form.getValue("u_string_full_utf8_1") + sp[i] + "\n");
    }
}

 

Hope it helps.

Thanks,
Murthy

View solution in original post

4 REPLIES 4

Murthy Ch
Giga Sage

Hi @lucky6 

Can you try below:

 

function onLoad() {
    //Type appropriate comment here, and begin script below  
    var getVal = g_form.getValue("u_string_full_utf8_1"); //replace with your field name
    var sp = getVal.split(",");
    for (var i = 0; i < sp.length; i++) {
        if (i == 0)
            g_form.setValue("u_string_full_utf8_1", sp[i] + "\n");
        else
            g_form.setValue("u_string_full_utf8_1", g_form.getValue("u_string_full_utf8_1") + sp[i] + "\n");
    }
}

 

Hope it helps.

Thanks,
Murthy

lucky6
Tera Contributor

Thanks murthy for the reply..

its populating only first value "123" I am.not getting other values in field.

Hi @lucky6 

Just updated the script. Can you try again

 

Thanks,
Murthy

lucky6
Tera Contributor

It's working..Thank you