Expand my Community achievements bar.

How to populate table rows with selected listbox items?

Avatar

Level 1

Hello,

I am trying to populate a table with selected listbox items. Each item should be a new row in the table. The picture below is the listbox and table I am using. I need to get the selected name to populate the Attendee column of the table when the user clicks the Add button. How do you do this with mutltiple attendees selected?

Listbox.jpg

Thank you,

Angie

5 Replies

Avatar

Level 10

Hi Angie,

To be able to get the multiple selections you must loop in the items of the listbox, verify if it is selected and then add it to the row if it is selected...

To loop through all items and verify it's item state, use the following code:

Avatar

Level 1

Thanks Magus069!

What about checking for duplicates? I don't want the user to select the same person twice.

Thanks,

Angie

Avatar

Level 10

So you're considering the fact the if the user clicks the button twice, the name will appear twice and you don't want this, right?

Then you must check if any value is the same than the one you are about to add in the row..

Avatar

Level 1

I think your code and mine maybe a little different.

Here is how I am doing it. i just can't get the duplicate check to work.

var total = 0;
var row = courseInfoSubform.tableSubform.Table1.Row1


for(i=0; i<courseInfoSubform.attendeeSubform.attendeeLB.length; i++)

{
  if(courseInfoSubform.attendeeSubform.attendeeLB.getItemState(i))
   {
   
     if(courseInfoSubform.tableSubform.Table1.Row1.attendeeTbl.isNull)
     {
     row.attendeeTbl.rawValue = courseInfoSubform.attendeeSubform.attendeeLB.getDisplayItem(i);
       }
    else
     {
    row = courseInfoSubform.tableSubform.Table1.Row1.instanceManager.addInstance(1);
row.attendeeTbl.rawValue = courseInfoSubform.attendeeSubform.attendeeLB.getDisplayItem(i);
 
     }
  }

}




Avatar

Level 10

Here you verify the same row in each loop, you create your var row with the value of Row1, to be able to check each rows you must declare the row var in the loop to be able to get each instances