Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Adding/removing a row from a table

Avatar

Former Community Member
Hi. I'm building a form that contains 2 tables. I need to find a way to add rows to the second table, based on whether or not the user has entered data into the last cell of each row on the first table.



The first table has 45 rows, but a user may only enter data into 2 of them -- so the second table would only need 2 rows.



Right now, my hamfisted solution is to have 45 rows in Table 2 -- and use presence to turn them on and off. This doesn't seem like the best solution, but I may be wrong, since I know next to nothing about JavaScript or FormCalc.



Miraculously, I've figured out how to use addInstance to make the rows appear in the second table. But I also need to delete the instance if the user later deletes the information from the cell in Table 1 that caused the instance to be added to Table 2.



Because the user may not add/delete information "in order", I can't count on subform[0] in Table 2 corresponding to the first occurrence in Table 1, subform[1] the second, etc.



So my question finally is: Is there a way to retrieve the index [n] of the subform added with addInstance, and use that to delete the added subform?



The document is an internal form for the school where I teach, so I'd rather not post it here -- but if anyone wants to look at it, I can email it to you.



Thanks much,

Nathan
0 Replies