Expand my Community achievements bar.

Single or multiple check box values displayed in a text field

Avatar

Level 4


My apologies, this may be a duplicate discussion.

I'm using the following script to display the values of check boxes in a text field.  I would like the word "and" to separate the values if two check boxes are selected. If more than two boxes are selected I want the values to be separated by a comma and then the last value be separated by "and".  Example of two check boxes selected:  A and B.  Example of two or more: A, B, C, and D.  Can this be done?

form1.page1.page1SF.programs::calculate - (JavaScript, client)

//displays the values of check boxes named programCB

var aChkBx = [];

var vChecks = programCB.all;

for (var a=0; a<vChecks.length;a++){

if(!vChecks.item(a).isNull) {

aChkBx.push(vChecks.item(a).rawValue);

}

}

this.rawValue = aChkBx.join(", ");

0 Replies
page footer