Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How to remove an item in the dropdown list ?

Avatar

Level 3

Hi all

thanks for your time.

I have a drop-down called "drp_names" in a dynamic table that the rows can repeat on clicking button, table SOM named "Body.Table1.Row1". what I want to do is how to delete the selected item in the first row to not let it appear on the drop-down in the second row.

thanks alot

2 Replies

Avatar

Level 3

Hello Karwan, what you want to do is to use the .deleteItem() function. I am not entirely understanding if the dropdowns is already prepopulated or how you initialize the content in the dropdown.

You need to supply this function with the index of the choice you want to remove, and honestly I am not entirely sure how to do this most elegant. Personally I have previously only used the function to remove the "currently" selected instance and I did that as:

    " form1.Body.drp_names.deleteItem(form1.Body.drp_names.selectedIndex)"

    

Nevertheless I havent been able to find a good way to extract an index of a specific entry. E.g finding the index (in dropdown2) of the entry chosen in dropdown1.

I think this might be a spaghetti way of coding it :

      form1.Body.drp_names2 = form1.Body.drp_names1

      form1.Body.drp_names2.deleteItem(form1.Body.drp_names2.selectedIndex)

I am certain there will be better ways of solving the problem. But this is a way I think of on the top of my head.

Nevertheless you need some quite extensive security (say you enter a value in the first dropdown, and it gets removed in the second and third etc. what happens if you change your mind on the first one? An easy way would probably be to make some kind of full reset of all the dropdowns if you go back and change something.)

All these things obviously depends on the looks and requirements of your document of course. And keep in mind my referencing is just for example.

Hope this was to some help.

Regards Mattias.