Expand my Community achievements bar.

SOLVED

Creating a list based on checkbox selections

Avatar

Level 1

Hi, I am new to LiveCycle. I would like to create a list at the end of a document that shows all checkbox selections throughout the document. Is this possible?

I'm using Livecycle Designer ES3.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 8

Create two ListBox objects at the end of your form; ListBox1 will display all the check boxes that are checked and ListBox2 for all of those that aren't.

The following code can be placed in the click event of a button or any event you want:

 

var vList = getCheck(form1,{});

ListBox1.clearItems();//Name of the list box that lists the checked fields

ListBox2.clearItems();//Name of the list box that lists the unchecked fields
for (var i in vList){
     if (vList[i].value=='0') //<----Value to change based on On/Off value assignments
          ListBox2.addItem(vList[i].caption,i);
     else
          ListBox1.addItem(vList[i].caption,i);
}

function getCheck(vNode,vChecks){
     if (vNode.className=="field" && vNode.resolveNode("ui.checkButton")!=null){
          vChecks[vNode.somExpression]={};
          vChecks[vNode.somExpression].caption=vNode.caption.value.text.value;
          vChecks[vNode.somExpression].value=vNode.rawValue;
     }
     if (vNode.className=="subform"){
          for (var a=0;a<vNode.nodes.length;a++){
               getCheck(vNode.nodes.item(a),vChecks);
          }
     }
     return vChecks;
}

This code assumes your root subform is form1 (the default in designer). It also assumes that all the names and captions for your check boxes are unique.

Now for an added feature you can place the following code in the change event of your ListBox's:

xfa.host.setFocus(this.boundItem(xfa.event.newText));

Displayed in the list boxes are all the captions for the checkboxes in your form. Click on any of the items in the list box and it will bring you to that check box.

Hope that's what you're looking for.

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Create two ListBox objects at the end of your form; ListBox1 will display all the check boxes that are checked and ListBox2 for all of those that aren't.

The following code can be placed in the click event of a button or any event you want:

 

var vList = getCheck(form1,{});

ListBox1.clearItems();//Name of the list box that lists the checked fields

ListBox2.clearItems();//Name of the list box that lists the unchecked fields
for (var i in vList){
     if (vList[i].value=='0') //<----Value to change based on On/Off value assignments
          ListBox2.addItem(vList[i].caption,i);
     else
          ListBox1.addItem(vList[i].caption,i);
}

function getCheck(vNode,vChecks){
     if (vNode.className=="field" && vNode.resolveNode("ui.checkButton")!=null){
          vChecks[vNode.somExpression]={};
          vChecks[vNode.somExpression].caption=vNode.caption.value.text.value;
          vChecks[vNode.somExpression].value=vNode.rawValue;
     }
     if (vNode.className=="subform"){
          for (var a=0;a<vNode.nodes.length;a++){
               getCheck(vNode.nodes.item(a),vChecks);
          }
     }
     return vChecks;
}

This code assumes your root subform is form1 (the default in designer). It also assumes that all the names and captions for your check boxes are unique.

Now for an added feature you can place the following code in the change event of your ListBox's:

xfa.host.setFocus(this.boundItem(xfa.event.newText));

Displayed in the list boxes are all the captions for the checkboxes in your form. Click on any of the items in the list box and it will bring you to that check box.

Hope that's what you're looking for.

Kyle

Avatar

Level 1

This is exactly what I needed! Thanks!