So, the way I see it, you actually have four scenarios. Nothing is checked, one item is checked, two items are checked, and three or more items are checked.
Here's how I did it.
I have four checkboxes all with the same name, cb. (You could have many more, and it wouldn't matter as long as they're all named the same thing.) I'm presuming that you will use the captions from the checkboxes as the text you want to enter. I called my text area where I enter the information tfSentence. (It's not a text field, it's just called "Text" in the Object Library.)
//we need to count how many boxes are checked
var checked = 0;
for (i=0; i<=cb.length; i++){
if (xfa.resolveNode("cb["+i+"]").rawValue == 1) checked ++;
}
//create a string variable to store our sentence
var str = "";
//look at the checked variable and choose our case from that
switch(checked){
case 0:
//you may want to do more than just type out a sentence here, like a message box
tfSentence.rawValue = "Nothing was selected";
break;
case 1:
//you can set text that will appear before your list of items here
//str = "preliminary text";
for (i=0; i<=cb.length; i++){
if (xfa.resolveNode("cb["+i+"]").rawValue == 1) str += xfa.resolveNode("cb["+i+"].caption.value.#text").value;
//you can set text to appear after your list of items here
//str += "ending text";
tfSentence.rawValue = str;
break;
case 2:
//str = "preliminary text";
for (i=0; i<=cb.length; i++){
if (xfa.resolveNode("cb["+i+"]").rawValue == 1){
if (checked == 1) str += " and " + xfa.resolveNode("cb["+i+"].caption.value.#text").value;
else str += xfa.resolveNode("cb[+i+"].caption.value.#text").value;
checked--;
}
}
//str+= "ending text";
tfSentence.rawValue = str;
break;
default:
//str = "preliminary text";
for (i=0; i<=cb.length; i++){
if (xfa.resolveNode("cb["+i+"]").rawValue == 1){
if (checked == 1) str += "and " + xfa.resolveNode("cb["+i+"].caption.value.#text").value;
else str += xfa.resolveNode("cb["+i+"].caption.value.#text").value + ", ";
checked--;
}
}
//str += "ending text";
tfSentence.rawValue = str;
break
}